Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        PlaneMeshTools.CreatePlane(
                1.0f,0.01f,
                2,2,
                this.material,
                this.gameObject);

        this.transform.position = Vector3.zero;
        this.transform.Translate(new Vector3(0f,0f,-0.03f));
        this._networkReference = GamePlayState.GetSupplyLines();
        this.gameObject.AddComponent<BoxCollider>();
        BoxCollider collider = this.gameObject.GetComponent<BoxCollider >();

        collider.enabled = true;
        collider.isTrigger = true;

        collider.size = new Vector3(
                collider.bounds.extents.x,
                collider.bounds.extents.y,
                10f);

        this.gameObject.AddComponent<Rigidbody>();
        Rigidbody rigidBody = this.gameObject.GetComponent<Rigidbody>();
        rigidBody.useGravity = false;

        this._isValid = true;
    }
Ejemplo n.º 2
0
    public void AddBuildingEntryPointsToNetwork(SupplyNetwork network)
    {
        buildings.ForEach( building =>
                {
                    // get the adjusted entry positions for this building.
                    List<Vector3> adjustedEntryPositions = building.LevelAdjustedEntryPointPosition();

                    // pass these off to our supply network.
                    List<int> nodeIds = network.AddNodeFromBuildingEntryPoints(adjustedEntryPositions);

                    // make sure that the building keeps a reference to the ids that were created.
                    building.nodeIdsForEntryPoints = nodeIds;
                });
    }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        UnityEngine.Object levelV0 = Resources.Load(@"LevelV0");
        GameObject levelV0Object = UnityEngine.Object.Instantiate(levelV0, Vector3.zero, Quaternion.identity) as GameObject;
        this.LevelData = levelV0Object.GetComponent(typeof(LevelV0)) as LevelV0;
        this.LevelData.Initialize();

        this.blueTeamProfile = new Profile("testProfile");
        this.redTeamProfile = new Profile("testEnemyTeam");

        this.redTeam = new Army(this.redTeamProfile);
        this.blueTeam = new Army(this.blueTeamProfile);

        squadIdToSquadInfo = new Dictionary<Guid, Squad>();

        this.redTeam.Squads.ForEach( squad => squadIdToSquadInfo[squad.id] = squad );
        this.blueTeam.Squads.ForEach( squad => squadIdToSquadInfo[squad.id] = squad );

        this.CurrentGameMode = GameMode.BlankState;
        this.CurrentInputState = InputState.BlankState;

        this.buildingIdToBuildingInfo = new Dictionary<Guid, Building>();

        List<Building> buildings = this.LevelData.Buildings;

        GamePlayState.supplyLines = new SupplyNetwork(this.blueTeam, this.LevelData, this);
        foreach(Building building in buildings)
        {
            this.buildingIdToBuildingInfo.Add(building.buildingId, building);

            if(building.isStartingPosition)
            {
                // if this building is a starting point for all of our units, then
                // we need to let our supply network 'know', so that it knows where to
                // position our units in the initial configuration.
                GamePlayState.supplyLines.MarkAsStartingPoint(building.nodeIdsForEntryPoints.First());
            }
        }

        // link up event handlers with the camera.
        if(Camera.allCameras.Length != 1)
        {
            throw new System.ArgumentException("we only expected one active camera");
        }

        Camera activeCamera = Camera.allCameras[0];
        TopDownCamera camera = activeCamera.GetComponentsInChildren<TopDownCamera>().First() as TopDownCamera;
        camera.ActionModeButtonPressed += this.ActionModeButtonPressed;
        this.Paused += camera.GamePausedHandler;
        this.UnPaused += camera.GameUnPausedHandler;
    }