示例#1
0
    public void ConstructBuilding(BuildingCore.Type type)
    {
        GameObject   newBuilding     = Instantiate(building, new Vector3((transform.position.x + 25) + 50 * ownedBuildings.Count, 1, (transform.position.z + 25) + 50 * ownedBuildings.Count), new Quaternion(0, 0, 0, 90), transform);
        BuildingCore newBuildingCore = newBuilding.GetComponent <BuildingCore>();

        newBuildingCore.masterRegion = regionHandle;
        newBuildingCore.type         = type;
        GetBuildingsInRegion();
    }
示例#2
0
 public void Right_PingWorkshopSlot(BuildingCore sender)
 {
     if (active)
     {
         if (sender = right_BuildingSelected)
         {
             Right_ShowBuildingContents(sender);
             Centre_RefreshTroopPins();
         }
     }
 }
示例#3
0
    public void Right_SelectBuilding(int type)
    {
        if (right_BuildingType != type)
        {
            right_BuildingCycle = -1;
        }

        right_BuildingType     = type;
        right_BuildingCycle    = (int)Mathf.Repeat(right_BuildingCycle + 1, Right_GetBuildingAmount(type));
        right_BuildingSelected = Right_GetOwnedBuilding(type, right_BuildingCycle);

        //Initialise the counters
        Right_InitialiseCounters();

        //Show that this building is selected on the counters
        Right_GetUIBuilding(type).GetChild(0).GetChild(2).GetChild(right_BuildingCycle).GetComponent <Outline>().effectColor = Color.red;

        //Show the contents of this building
        Right_ShowBuildingContents(right_BuildingSelected);

        //Show which region this building belongs to
        Centre_InitialiseMap(HighLightMode.Darken);
        Centre_HighlightMap(right_BuildingSelected.masterRegion, HighLightMode.Lighten);
    }
示例#4
0
    void Right_ShowBuildingContents(BuildingCore target)
    {
        //Health
        right_SubmenuBuildingHealthBar.fillAmount = right_BuildingSelected.HealthPCT();
        right_SubmenuBuildingHealthText.text      = right_BuildingSelected.health.ToString("F0") + "/<b>" + right_BuildingSelected.healthMax.ToString("F0") + "</b>";

        switch (target.type)
        {
        case BuildingCore.Type.Barracks:
            right_SubmenuSelectedText.text = "Barracks (" + target.masterRegion + ")";
            Right_ToggleUIBuilding(0);

            //QUEUED UNITS

            //Initialise units
            for (int unit = 0; unit < 3; unit++)
            {
                Right_GetUISubmenuBuilding(0).GetChild(0).GetChild(0).GetChild(0).GetChild(unit).gameObject.SetActive(false);
            }

            GameObject barracksTargetQueued;
            switch (target.barracks.ownedUnit.queued)
            {
            case TroopCore.Type.Ambush:
                //targetQueuedUnit = Right_GetUISubmenuBuilding(0).GetChild(0).GetChild(0).GetChild(0).GetChild(0).gameObject;
                barracksTargetQueued = GameObject.Find("Barracks/Queued Units/Slot 1/Unit Parent/Ambush");
                barracksTargetQueued.SetActive(true);
                Right_UpdateBarracksSlot(target.barracks);
                break;

            case TroopCore.Type.Assault:
                //targetQueuedUnit = Right_GetUISubmenuBuilding(0).GetChild(0).GetChild(0).GetChild(0).GetChild(1).gameObject;
                barracksTargetQueued = GameObject.Find("Barracks/Queued Units/Slot 1/Unit Parent/Assault");
                barracksTargetQueued.SetActive(true);
                Right_UpdateBarracksSlot(target.barracks);
                break;

            case TroopCore.Type.Defender:
                //targetQueuedUnit = Right_GetUISubmenuBuilding(0).GetChild(0).GetChild(0).GetChild(0).GetChild(2).gameObject;
                barracksTargetQueued = GameObject.Find("Barracks/Queued Units/Slot 1/Unit Parent/Defender");
                barracksTargetQueued.SetActive(true);
                Right_UpdateBarracksSlot(target.barracks);
                break;

            case TroopCore.Type.None:
                break;
            }


            //TRAINED UNITS

            //Initialise units
            for (int unit = 0; unit < 3; unit++)
            {
                Right_GetUISubmenuBuilding(0).GetChild(1).GetChild(0).GetChild(0).GetChild(unit).gameObject.SetActive(false);
            }

            if (target.barracks.ownedUnit.reference)
            {
                GameObject barracksTargetTrained;
                switch (target.barracks.ownedUnit.unit)
                {
                case TroopCore.Type.Ambush:
                    //targetTrainedUnit = Right_GetUISubmenuBuilding(0).GetChild(1).GetChild(0).GetChild(0).GetChild(0).gameObject;
                    barracksTargetTrained = GameObject.Find("Barracks/Trained Units/Slot 1/Unit Parent/Ambush");
                    barracksTargetTrained.SetActive(true);
                    break;

                case TroopCore.Type.Assault:
                    //targetTrainedUnit = Right_GetUISubmenuBuilding(0).GetChild(1).GetChild(0).GetChild(0).GetChild(1).gameObject;
                    barracksTargetTrained = GameObject.Find("Barracks/Trained Units/Slot 1/Unit Parent/Assault");
                    barracksTargetTrained.SetActive(true);
                    break;

                case TroopCore.Type.Defender:
                    //targetTrainedUnit = Right_GetUISubmenuBuilding(0).GetChild(1).GetChild(0).GetChild(0).GetChild(2).gameObject;
                    barracksTargetTrained = GameObject.Find("Barracks/Trained Units/Slot 1/Unit Parent/Defender");
                    barracksTargetTrained.SetActive(true);
                    break;

                case TroopCore.Type.None:
                    barracksTargetTrained = null;
                    break;

                default:
                    barracksTargetTrained = null;
                    break;
                }

                //Setup the draggable script
                if (barracksTargetTrained != null)
                {
                    Draggable drag = barracksTargetTrained.GetComponent <Draggable>();
                    drag.unit = target.barracks.ownedUnit.reference;
                }
            }

            Centre_RefreshTroopPaths();
            break;

        case BuildingCore.Type.Granary:
            right_SubmenuSelectedText.text = "Granary (" + target.masterRegion + ")";
            Right_ToggleUIBuilding(1);

            Centre_RefreshTroopPaths();
            break;

        case BuildingCore.Type.Workshop:
            right_SubmenuSelectedText.text = "Workshop (" + target.masterRegion + ")";
            Right_ToggleUIBuilding(2);



            //TROOPS

            //Initialise units
            for (int unit = 0; unit < 5; unit++)
            {
                Right_GetUISubmenuBuilding(2).GetChild(1).GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(unit).gameObject.SetActive(false);
            }

            GameObject workshopTargetQueued;

            TroopCore.Type tester;
            if (target.workshop.ownedUnit.reference)
            {
                tester = target.workshop.ownedUnit.reference.type;
            }
            else
            {
                tester = target.workshop.ownedUnit.queued;
            }

            switch (tester)
            {
            case TroopCore.Type.BarracksBuilder:
                workshopTargetQueued = GameObject.Find("Workshop/Troops/Slots/Slot 1/Background/Unit Parent/Barracks Builder");
                workshopTargetQueued.SetActive(true);
                Right_UpdateWorkshopSlot(target.workshop);
                break;

            case TroopCore.Type.GranaryBuilder:
                workshopTargetQueued = GameObject.Find("Workshop/Troops/Slots/Slot 1/Background/Unit Parent/Granary Builder");
                workshopTargetQueued.SetActive(true);
                Right_UpdateWorkshopSlot(target.workshop);
                break;

            case TroopCore.Type.WorkshopBuilder:
                workshopTargetQueued = GameObject.Find("Workshop/Troops/Slots/Slot 1/Background/Unit Parent/Workshop Builder");
                workshopTargetQueued.SetActive(true);
                Right_UpdateWorkshopSlot(target.workshop);
                break;

            case TroopCore.Type.SiegeCatapult:
                workshopTargetQueued = GameObject.Find("Workshop/Troops/Slots/Slot 1/Background/Unit Parent/Siege Catapult");
                workshopTargetQueued.SetActive(true);
                Right_UpdateWorkshopSlot(target.workshop);
                break;

            case TroopCore.Type.SiegeRam:
                workshopTargetQueued = GameObject.Find("Workshop/Troops/Slots/Slot 1/Background/Unit Parent/Siege Ram");
                workshopTargetQueued.SetActive(true);
                Right_UpdateWorkshopSlot(target.workshop);
                break;

            case TroopCore.Type.None:
                workshopTargetQueued = null;
                break;

            default:
                workshopTargetQueued = null;
                break;
            }

            //Setup the draggable script
            if (workshopTargetQueued != null)
            {
                Draggable drag = workshopTargetQueued.GetComponent <Draggable>();
                drag.unit = target.workshop.ownedUnit.reference;
            }

            /*
             * //TRAINED UNITS
             *
             * //Initialise units
             * for (int unit = 0; unit < 3; unit++)
             * {
             *  Right_GetUISubmenuBuilding(0).GetChild(1).GetChild(0).GetChild(0).GetChild(unit).gameObject.SetActive(false);
             * }
             *
             * if (target.workshop.ownedUnit.reference)
             * {
             *  GameObject workshopTargetTrained;
             *  switch (target.workshop.ownedUnit.unit)
             *  {
             *      case UnitCore.Type.Ambush:
             *          workshopTargetTrained = GameObject.Find("Workshop/Trained Units/Slot 1/Unit Parent/Ambush Draggable");
             *          workshopTargetTrained.SetActive(true);
             *          break;
             *      case UnitCore.Type.Assault:
             *          workshopTargetTrained = GameObject.Find("Workshop/Trained Units/Slot 1/Unit Parent/Assault Draggable");
             *          workshopTargetTrained.SetActive(true);
             *          break;
             *      case UnitCore.Type.Defender:
             *          workshopTargetTrained = GameObject.Find("Workshop/Trained Units/Slot 1/Unit Parent/Defender Draggable");
             *          workshopTargetTrained.SetActive(true);
             *          break;
             *      case UnitCore.Type.None:
             *          workshopTargetTrained = null;
             *          break;
             *      default:
             *          workshopTargetTrained = null;
             *          break;
             *  }
             * }
             */

            Centre_RefreshTroopPaths();
            break;
        }
    }
示例#5
0
    public void Centre_DrawBuildingDefaultPath(BuildingCore target)
    {
        List <int> path = target.defaultRoute;

        for (int instruction = 0; instruction < path.Count - 1; instruction++)
        {
            int action = path[instruction + 1] - path[instruction];
            int dir    = 0;
            switch (action)
            {
            //UP
            case -3:
                dir = 0;
                break;

            //DOWN
            case 3:
                dir = 1;
                break;

            //LEFT
            case -1:
                dir = 2;
                break;

            //RIGHT
            case 1:
                dir = 3;
                break;
            }

            TroopCore.Type tester = TroopCore.Type.None;
            if (target.type == BuildingCore.Type.Barracks)
            {
                tester = target.barracks.ownedUnit.queued;
            }
            else if (target.type == BuildingCore.Type.Workshop)
            {
                tester = target.workshop.ownedUnit.queued;
            }

            Color to = Color.white;
            switch (tester)
            {
            case TroopCore.Type.Ambush:
                to = Color.green;
                break;

            case TroopCore.Type.Assault:
                to = Color.red;
                break;

            case TroopCore.Type.Defender:
                to = Color.blue;
                break;

            case TroopCore.Type.BarracksBuilder:
                to = Color.yellow;
                break;

            case TroopCore.Type.GranaryBuilder:
                to = Color.yellow;
                break;

            case TroopCore.Type.WorkshopBuilder:
                to = Color.yellow;
                break;

            case TroopCore.Type.SiegeCatapult:
                to = Color.gray;
                break;

            case TroopCore.Type.SiegeRam:
                to = Color.gray;
                break;
            }
            centre_NavT.GetChild(path[instruction]).GetChild(dir).GetChild(0).GetComponent <Image>().color = to;
        }
    }