Skip to content
Permalink
548d0ea25a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
65 lines (58 sloc) 1.71 KB
using UnityEngine;
using System.Collections;
using RTS;
public class Capacitor : Building {
public int addedCapacitanceLimit;
public Vector3 center;
public float radius;
private float angle;
public int maxWorkers;
private int currentworkers;
private Vector3 currentpoint;
private float step;
protected override void Awake() {
base.Awake ();
}
protected override void Start () {
base.Start ();
player.addResourceLimit (ResourceType.Capacitance, addedCapacitanceLimit);
center = transform.position;
step = 2 * Mathf.PI / maxWorkers;
angle = 0;
currentworkers = transform.childCount;
currentpoint = new Vector3 (center.x + radius, center.y, center.z + radius);
CreateUnit ("Worker");
CreateUnit ("Worker");
CreateUnit ("Worker");
CreateUnit ("Worker");
CreateUnit ("Worker");
CreateUnit ("Worker");
}
protected override void Update () {
base.Update ();
if (!constructing) {
}
}
protected override void OnGUI() {
base.OnGUI ();
}
protected override void OnDestroy() {
player.addResourceLimit (ResourceType.Capacitance, addedCapacitanceLimit * -1);
}
public void addResource(ResourceType resourceName, int value) {
player.addResource (resourceName, value);
}
public void addResourceLimit (ResourceType resourceName, int value) {
player.addResourceLimit (resourceName, value);
}
protected override void InstantiateUnit() {
if (currentworkers < maxWorkers) {
angle += step;
Vector3 offset = new Vector3 (Mathf.Sin (angle) * radius, 0, Mathf.Cos (angle) * radius);
currentpoint = center + offset;
Unit newUnit = Instantiate (buildQueue.Dequeue (), currentpoint, transform.rotation) as Unit;
newUnit.transform.parent = this.transform;
currentworkers++;
}
}
}