Пример #1
0
        // Use this for initialization
        void Start()
        {
            SquadsInNode = new List<Squad>();

            /// we'll be referencing this child component regularly, so store a local copy.
            this.SquadsInNodeChildObject = this.gameObject.GetComponentInChildren<UnitListControl>() as UnitListControl;
            Orders.OrderAdded += this.SquadsInNodeChildObject.OnOrderAdded;
        }
Пример #2
0
    // Use this for initialization
    public void Start()
    {
        if(isInitialized == false)
        {
            //PlaneMeshTools.CreatePlane(10f, 10f, 1, 1, material, this.gameObject);
            PlaneMeshTools.CreatePlane(
                    buildingWidth,buildingWidth,
                    2,2,
                    this.material,
                    this.gameObject);

            this.gameObject.AddComponent<MeshCollider>();
            MeshCollider collider = this.gameObject.GetComponent<MeshCollider>();
            MeshFilter mesh = this.gameObject.GetComponent<MeshFilter>();
            collider.sharedMesh = mesh.sharedMesh;
            this._entryPointPositions = new List<Vector3>();

            UnityEngine.Object doorResource = Resources.Load(@"Door");
            Vector3 doorPosition = new Vector3(
                    this.transform.position.x + mesh.sharedMesh.bounds.center.x,
                    this.transform.position.y,
                    -0.01f);

            this._entryPointPositions.Add(doorPosition);

            UnityEngine.Object.Instantiate(
                    doorResource,
                    doorPosition,
                    Quaternion.identity);

            isInitialized = true;

            Transform cube = this.transform.FindChild("cube");
            cube.transform.localScale = new Vector3(
                    buildingWidth,
                    buildingWidth,
                    cube.transform.localScale.z
                    );

            cube.transform.position = new Vector3(
                    cube.transform.position.x + buildingWidth/2,
                    cube.transform.position.y + buildingWidth/2,
                    cube.transform.position.z
                    );

            SquadsInBuilding = new List<Squad>();

            /// we'll be referencing this child component regularly, so store a local copy.
            this.SquadsInBuildingChildObject = this.gameObject.GetComponentInChildren<UnitListControl>() as UnitListControl;
            Orders.OrderAdded += this.SquadsInBuildingChildObject.OnOrderAdded;
        }

        if(this.NodeIdsInHousing() == null)
        {
            this.nodeIdsForEntryPoints = new List<int>();
        }
        this.UnitCountText = this.gameObject.GetComponentInChildren<TextMesh>() as TextMesh;
    }