The movable, fighting, people that wander around our map
Inheritance: BaseType
Beispiel #1
0
    //Initialize the Troop as Battlefield unit. Called Exclusively By BattleFieldManager
    public static GameObject instantiate(Troop troopInfo, Vector2 position, GameObject mother)
    {
        // Initialize GameObject
        GameObject g = new GameObject(troopInfo.Faction.Name.ToString() + " " + troopInfo.Type.ToString());
        g.tag = "Unit";
        g.transform.position = new Vector3(position.x, position.y, BattleFieldManager.troopHeight);
        g.transform.SetParent(mother.transform);
        g.AddComponent<CircleCollider2D>().radius = colliderSize;  //This is for making hovering highlight happen

        /* Selection Process is gonna be done by bounding box check at BattleFieldManager level
        g.AddComponent<CircleCollider2D>().isTrigger = true;
        g.GetComponent<CircleCollider2D>().radius = 2f;
        g.AddComponent<Rigidbody2D>().gravityScale = 0f;
        */
        TroopOnField t = g.AddComponent<TroopOnField>();
        t.mother = mother.GetComponent<BattleFieldManager>();

        t.troop_stat = g.AddComponent<TroopStats>();
        t.troop_stat.initialize(troopInfo);
        t.troop_graphic = g.AddComponent<TroopGraphic>();
        t.troop_graphic.initialize(t.troop_stat);

        //Change Scale To Make The Icon Size Reasonable
        t.transform.localScale = Vector3.one * scale;

        //State Controller Machine to be in charge of everything
        t.controller = new TroopStateController(t);

        return g;
    }
Beispiel #2
0
    void Start()
    {
        GetComponent<Renderer>().enabled = true;

        originalColor = gameObject.GetComponent<Renderer> ().material.color;
        transparentColor = new Color(originalColor.r, originalColor.g, originalColor.b, 0.5f);

        gameObject.GetComponent<LOSEntity>().RevealState = LOSEntity.RevealStates.Fogged;
        gameObject.GetComponent<LOSEntity>().enabled = false;

        //Make the gameObject a bit transparent. Hacky hacky
        originalMaterials = new List<Material>();
        foreach (Material material in GetComponent<Renderer>().materials)
        {
            Material originalMaterial = new Material(material);
            originalMaterials.Add(originalMaterial);

            material.SetFloat("_Mode", 2);
            material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
            material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
            material.SetInt("_ZWrite", 0);
            material.DisableKeyword("_ALPHATEST_ON");
            material.EnableKeyword("_ALPHABLEND_ON");
            material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
            material.renderQueue = 3000;
            material.color = transparentColor;
        }
        collision = false;
        counterCollision = 0;

        t = new Troop(GameController.Instance.getSelectedUnits().units);
    }
Beispiel #3
0
 public void initialize(Troop troop)
 {
     type = troop.Type;
     rank = troop.Rank;
     number = troop.Number;
     morale = troop.Morale * rankMultiplier;
     stamina = stamina_threshold = MAX_STAT * rankMultiplier;
 }
 void DamageGate(int troopAttackValue, GameElement attackElement, Troop _troop, Gate gateToDamage)
 {
     if(gateToDamage.CanDamageGate)
     {
         gateToDamage.TakeDamage(troopAttackValue, attackElement);
         KillTroop(_troop);
     }
 }
Beispiel #5
0
        private void ReadDefenseToTroop(JToken json, Troop result)
        {
            int? front = (int?)json["Fdef"];
            int? rear = (int?)json["Rdef"];

            if (front == null || rear == null)
            {
                result.Defense = null;
                return;
            }

            result.Defense.Front = (int)front;
            result.Defense.Rear = (int)rear;
        }
Beispiel #6
0
 public Report(
     int attacker,
     int attackerVillage,
     int defender,
     int defenderVillage,
     Troop[] attackerTroops,
     Troop[] defenderTroops,
     Troop[] supportTroops)
     : this()
 {
     _attacker = attacker;
     _defender = defender;
     _attackerVillage = attackerVillage;
     _defenderVillage = defenderVillage;
     _attackerTroops = attackerTroops;
     _defenderTroops = defenderTroops;
     _supportTroops = supportTroops;
 }
    void GameUpdate()
    {
        timeElapsed += Time.deltaTime;

        //if (troopIndex < troopLoadout.Length){
        if(!isEmpty){
            if (timeElapsed > troopUnit.spawnTime){
                for (int i = 0; i < troopUnit.groupSize; i++){
                    troopLocation = troopLocations[troopUnit.spawnLocationIndex];
                    spawn = Graveyard.graveyard.CheckTombstone(troopUnit.unit.name);
                    //Debug.Log(troopUnit.unit.name+" : "+spawn);
                    if (spawn != null) {
                        //ressurect the unit, reset stats, place at it's pod location
                        spawn.GetComponent<Unit>().Ressurect(troopLocation);
                        //spawn.gameObject.SetActive(true);
                        //Graveyard.graveyard.tombstones[troopUnit.unit.name].RemoveAt(0);
                    } else {
                        spawn = Instantiate(troopUnit.unit);
                        //add to Unit Layer
                        spawn.transform.position = troopLocation;
                        //choose unit's AI targeting and send
                        //WalkScript().walk
                    }
                    spawn.transform.parent = LayerEnemyScript.enemyLayer.transform; //LayerUnitScript.unitLayer.transform;
                    Walk walk = spawn.GetComponent<Walk>();
                    walk.target = GameHandler.handler.mainBaseGame; //PlayerStart.playerStart.main;
                    //walk.Repath();
                    spawn = null;
                }
                troopIndex++;
                if (troopIndex < troopLoadout.Length){
                    troopUnit = SetTroopLoadout();
                } else {
                    isEmpty = true;
                    Debug.Log("Pod Is Empty!");
                }
            }
        }
    }
Beispiel #8
0
 public void manageArrival(Troop troop, int Target)
 {
     factories[Target].UnderAttack = false;
     if (troop.ObjectType != factories[Target].ObjectType)
     {
         if (troop.Elements > factories[Target].Elements)
         {
             factories[Target].Elements = troop.Elements - factories[Target].Elements;
             factories[Target].Elements = Math.Min(factories[Target].Elements, factories[Target].MaxElements);
             factories[Target].ObjectType = troop.ObjectType;
         }
         else
         {
             factories[Target].Elements -= troop.Elements;
         }
     }
     else
     {
         factories[Target].Elements += troop.Elements;
         factories[Target].Elements = Math.Min(factories[Target].Elements, factories[Target].MaxElements);
     }
 }
Beispiel #9
0
 public virtual void TroopEndPath(Troop troop)
 {
 }
 /// <summary>
 /// Just a test for creating troops
 /// </summary>
 /// <returns></returns>
 Troop CreateTroop()
 {
     Troop t = new Troop("example");
     return t;
 }
Beispiel #11
0
 public Troop CreateTroop(Troop.TroopType troopType, Level.LevelInstance level)
 {
     return Troop.createTroop (troopType, this, level);
 }
Beispiel #12
0
 public virtual void TroopApplyTroopEvent(TroopEvent te, Troop troop)
 {
 }
    void Update()
    {
        t += Time.deltaTime;
        RTSmouse();
        if (Input.GetMouseButtonDown(1))
        {
            LayerMask clickableLayer = (1 << LayerMask.NameToLayer("click"));
            Ray r = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit h;
            if (Physics.Raycast(r, out h, 50.0f, clickableLayer))
            {
                Deselect();
                if ((place != null || place != h.collider.gameObject) && lerpTime == 0)
                {
                    place = h.collider.gameObject;
                    print(place);
                    timenow = Time.time;
                    adjust = new Vector3(place.transform.position.x, transform.position.y, place.transform.position.z);
                    distToLerp = Vector3.Distance(transform.position, adjust);
                    isSelected = true;
                }

            }
        }

        if (isSelected)
        {
            buttons.SetActive(true);
            t1 = place.GetComponent<Soldier>().troop;

            nameInfo.text = t1.name;
            infoInfo.text = "Battles Won: " + t1.battlesWon +
                            "\nLoad Exp: " + t1.loadExp +
                            "\nAim Exp: " + t1.aimExp +
                           "\nSpot Exp: " + t1.spotExp;

            float distCovered = (Time.time - timenow) * 1f;
            float fracJourney = distCovered / distToLerp;
            lerpTime += Time.deltaTime;
            transform.position = Vector3.Lerp(transform.position, adjust, fracJourney);

        }

        if (Input.GetMouseButtonDown(0))
        {
            dragOrigin = Input.mousePosition;
            return;
        }

        if (!Input.GetMouseButton(0)) return;

        Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
        Vector3 move = new Vector3(pos.x * dragSpeed, 0, pos.y * dragSpeed);

        transform.Translate(move, Space.Self);
    }
Beispiel #14
0
 public virtual void TroopCastStratagem(Troop sending, Troop receiving, Stratagem stratagem)
 {
 }
Beispiel #15
0
 public virtual void TroopAmbush(Troop troop)
 {
 }
 public ApplyingTroop(Troop a, Applier p, int i)
 {
     this.troop = a;
     this.applier = p;
     this.applierID = i;
 }
Beispiel #17
0
 public virtual void TroopAntiAttack(Troop sending, Troop receiving)
 {
 }
Beispiel #18
0
 public virtual void TroopDiscoverAmbush(Troop sending, Troop receiving)
 {
 }
Beispiel #19
0
 public virtual void TroopEndCutRouteway(Troop troop, bool success)
 {
 }
Beispiel #20
0
 public virtual void TroopCreate(Troop troop)
 {
 }
Beispiel #21
0
 public virtual void TroopCombatMethodAttack(Troop sending, Troop receiving, CombatMethod combatMethod)
 {
 }
Beispiel #22
0
 public virtual void TroopAttract(Troop troop, Troop caster)
 {
 }
Beispiel #23
0
 public virtual void TroopRumour(Troop troop)
 {
 }
Beispiel #24
0
 public virtual void TroopChaos(Troop troop, bool deepChaos)
 {
 }
Beispiel #25
0
 public void TroopRemoved(Troop troop)
 {
     gateTroops.Remove (troop);
 }
Beispiel #26
0
 public virtual void TroopGetNewCaptive(Troop troop, PersonList personlist)
 {
 }
Beispiel #27
0
 public void StopManagingTroop(Troop _troop)
 {
     troops.Remove (_troop);
 }
Beispiel #28
0
 public virtual void TroopGetSpreadBurnt(Troop troop)
 {
 }
Beispiel #29
0
    public void createBuilding(GameObject prefab, Vector3 position, Troop t)
    {
        GameObject building = Instantiate(prefab, position, gameObject.transform.rotation) as GameObject;

        building.transform.SetParent(buildingsParent.transform);

        building.tag = t.units[0].gameObject.tag;

        Identity newIden = building.GetComponent<Identity>();
        if (newIden != null) newIden.player = t.units[0].GetComponent<Identity>().player;

        LOSEntity fow = building.GetComponent<LOSEntity>();
        if (fow != null) fow.IsRevealer = false;

        addSelectedPrefab(building);
        addTeamCirclePrefab(building);

        BuildingConstruction build = building.GetComponent<BuildingConstruction>();

        if (build != null)
        {
            build.setFinalMesh();

            building.GetComponent<MeshFilter>().mesh = build.getInitialMesh().GetComponent<MeshFilter>().sharedMesh;

            build.setConstructionOnGoing(true);

        }

        //building.GetComponent<BuildingConstruction>().setConstructionOnGoing(true);

        //foreach (var unit in t.units) unit.GetComponent<Construct>().SetBuildingToConstruct(building);

        foreach (var unit in t.units)
        {
            Construct scriptConstruct = unit.GetComponent<Construct>();

            if (scriptConstruct != null)
            {

                if (scriptConstruct.getConstruct() || scriptConstruct.getInConstruction())
                {
                    scriptConstruct.setConstruct(false);
                    scriptConstruct.SetInConstruction(false);
                    scriptConstruct.getBuildingToConstruct().GetComponentOrEnd<BuildingConstruction>().deleteUnit(unit);
                }
                scriptConstruct.SetBuildingToConstruct(building);

            }
        }

        if (building.tag == "Enemy")
        {
            updateResource(DataManager.Instance.unitDatas[building.gameObject.GetComponent<Identity>().unitType].resourceCost, "Enemy");
        }

        buildingConstruction(position, t);
    }
Beispiel #30
0
 public virtual void TroopLevyFieldFood(Troop troop, int food)
 {
 }
Beispiel #31
0
 public virtual void TroopBreakWall(Troop troop, Architecture architecture)
 {
 }
Beispiel #32
0
 public virtual void TroopNormalAttack(Troop sending, Troop receiving)
 {
 }
Beispiel #33
0
 private void ReadSpecialAbilities(JToken json, Troop result)
 {
     var value = (string)json["Special"];
     result.SpecialAbilities = ParseSpecialAbilities(value);
 }
Beispiel #34
0
 public virtual void TroopOccupyArchitecture(Troop troop, Architecture architecture)
 {
 }
Beispiel #35
0
 public virtual void TroopApplyStunt(Troop troop, Stunt stunt)
 {
 }
Beispiel #36
0
 public virtual void TroopOutburst(Troop troop, OutburstKind kind)
 {
 }
Beispiel #37
0
 public Troop CreateTroop(Troop.TroopType troopType)
 {
     return CreateTroop (troopType, Level.Current);
 }
Beispiel #38
0
 public virtual void TroopPathNotFound(Troop troop)
 {
 }
Beispiel #39
0
 public void onTroopHit(Troop t)
 {
     destroy();
 }
Beispiel #40
0
 public virtual void TroopPersonChallenge(int win, Troop sourceTroop, Person source, Troop destinationTroop, Person destination)
 {
 }
 //private Graveyard graveyard;
 //private GameHandler handler;
 // Use this for initialization
 void Start()
 {
     if (pod == null){
         DontDestroyOnLoad(gameObject);
         pod = this;
     } else {
         Destroy(gameObject);
     }
     troopUnit = SetTroopLoadout();
     //graveyard = Graveyard.graveyard;
     //handler = GameHandler.handler;
 }
Beispiel #42
0
 public virtual void TroopPersonControversy(bool win, Troop sourceTroop, Person source, Troop destinationTroop, Person destination)
 {
 }
Beispiel #43
0
    public static Troop createTroop(Troop.TroopType type, Player team, Level.LevelInstance level)
    {
        Spritable s = createSpritable();
        s.gameObject.AddComponent<Troop>();
        Troop t = s.GetComponent<Troop>();
        t.name = type.ToString () + " Troop";

        t.init(type, team, level);

        t.Costume = "BlueCircle";

        return t;
    }
Beispiel #44
0
 void KillTroop(Troop _troop)
 {
     _troop.EnterGateEffect();
 }
Beispiel #45
0
    void Awake()
    {
        // First we check if there are any other instances conflicting
        if (Instance != null && Instance != this)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }

        triangleFormation = false;
        // Here we save our singleton instance
        Instance = this;

        troops = new List<Troop>();
        allAllyUnits = new List<GameObject>();
        allEnemyUnits = new List<GameObject>();
        allAllyArmy = new List<GameObject>();
        allAllyBuildings = new List<GameObject>();
        allAllyTownCentres = new List<GameObject>();
        allAllyCivilians = new List<GameObject>();
        allEnemyArmy = new List<GameObject>();
        allEnemyBuildings = new List<GameObject>();
        allEnemyTownCentres = new List<GameObject>();
        allEnemyCivilians = new List<GameObject>();
        selectedUnits = new Troop();
        selectedUnits.units = new List<GameObject>();

        for (int i = 0; i<10; i++)
        {
            troops.Add(new Troop());
        }

        GameStatistics.resetStatistics();
    }
Beispiel #46
0
    // Use this for initialization
    void Start()
    {
        selectedUnits = new Troop();
        initResourceValues();
        if (!GameData.sceneFromMenu)
        {
            spawnRandomObjectives();
        }
        placing = false;

        AudioListener.volume = nivelMusic;
    }
Beispiel #47
0
 public void ManageTroop(Troop _troop)
 {
     troops.Add (_troop);
 }
Beispiel #48
0
    public void attack(GameObject enemy)
    {
        Troop troop = new Troop(selectedUnits.units);
        if (troop.units.Count != 0)
        {
            AttackController atkController;
            foreach (var unit in troop.units)
            {
                //Reset construction
                Construct scriptConstruct = unit.GetComponent<Construct>();

                if (scriptConstruct != null)
                {

                    if (scriptConstruct.getConstruct() || scriptConstruct.getInConstruction())
                    {
                        scriptConstruct.setConstruct(false);
                        scriptConstruct.SetInConstruction(false);
                        scriptConstruct.getBuildingToConstruct().GetComponentOrEnd<BuildingConstruction>().deleteUnit(unit);
                    }
                }

                atkController = unit.GetComponent<AttackController>();
                atkController.attack(enemy);
            }
        }
    }
Beispiel #49
0
 public virtual void TroopReceiveCriticalStrike(Troop sending, Troop receiving)
 {
 }
Beispiel #50
0
 public virtual void TroopCastDeepChaos(Troop sending, Troop receiving)
 {
 }
Beispiel #51
0
 public IEnumerator LookForEnemy()
 {
     while(true)
     {
         Collider[] targets = Physics.OverlapSphere(transform.position, troopStats.RangeOfSight); // read all enemies around
         foreach(Collider c in targets) // for each enemy found
         {
             Troop enemyScript = c.GetComponent<Troop>();
             if(c.gameObject.layer == LayerMask.NameToLayer("Troop") && CheckIsEnemy(enemyScript.TroopTeam))
             {
                 if(!combatTarget ) // make sure forget the old target
                 {
                     combatTarget = c.GetComponent<Troop>(); // assign the target
                 }
             }
         }
         yield return null; // every frame
     }
 }
Beispiel #52
0
 public virtual void TroopReceiveWaylay(Troop sending, Troop receiving)
 {
 }
Beispiel #53
0
    private void moveUnits(GameObject target, Troop troop)
    {
        if (troop.hasMovableUnits())
        {
            foreach (var unit in troop.units)
            {

                Construct scriptConstruct = unit.GetComponent<Construct>();

                if (scriptConstruct != null)
                {

                    if (scriptConstruct.getConstruct() || scriptConstruct.getInConstruction())
                    {
                        scriptConstruct.setConstruct(false);
                        scriptConstruct.SetInConstruction(false);
                        scriptConstruct.getBuildingToConstruct().GetComponentOrEnd<BuildingConstruction>().deleteUnit(unit);
                    }

                }

                UnitMovement script = unit.GetComponentInParent<UnitMovement>();
                if (script != null)
                {
                    script.startMoving(target);
                    target.GetComponent<timerDeath>().AddUnit(unit);
                }

            }
        }
        else
        {
            foreach (var unit in troop.units)
            {
                Spawner script = unit.GetComponentInParent<Spawner>();
                if (script != null)
                {
                    script.RallyPoint = target.transform.position;
                }
            }
            Destroy(target.gameObject);
        }
    }
Beispiel #54
0
 public virtual void TroopRecoverFromChaos(Troop troop)
 {
 }
Beispiel #55
0
    // Update is called once per frame
    void Update()
    {
        // if (Input.GetKey(KeyCode.P)) ToGameStatistics(Vector3.zero, Player.CPU1, Victory.Annihilation);

        if (Input.mousePosition.y > Screen.height * UIheight) {

            //Left Click Manager
            if (Input.GetMouseButtonDown (0)) {
                isSelecting = true;
                mPos = Input.mousePosition;

                //Click detection
                RaycastHit hitInfo = new RaycastHit ();
                bool hit = Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hitInfo);
                if (hit) {

                    GameObject selectedGO = hitInfo.transform.gameObject;
                    if (hitInfo.transform.gameObject.tag == "Ally") {

                        if (!Input.GetKey (KeyCode.LeftControl))
                            ClearSelection ();

                        if (!selectedUnits.units.Contains (selectedGO))
                            selectedUnits.units.Add (selectedGO);

                        selectedUnits.FocusedUnit = selectedGO;
                        Transform projector = selectedGO.transform.FindChild ("Selected");
                        if (projector != null)
                            projector.gameObject.SetActive (true);
                        hud.updateSelection (selectedUnits);

                    } else {
                        // Debug.Log("not Ally");
                    }
                } else {
                    // Debug.Log("No hit");
                }
            }

            if (Input.GetMouseButtonDown (1)) {

                //Click detection
                RaycastHit hitInfo = new RaycastHit ();
                bool hit = Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hitInfo);
                GameObject target;
                if (hit) {

                    if (AI.Instance.resources.Contains (hitInfo.transform.gameObject.tag))
                        moveUnits (hitInfo.transform.gameObject);
                    else if (hitInfo.transform.gameObject.tag == "Enemy") {
                        Debug.Log ("ataacaaarrr");
                        GameObject enemy = hitInfo.transform.gameObject;
                        attack (enemy);
                    } else if (hitInfo.transform.gameObject.tag == "Ally" && hitInfo.transform.gameObject.GetComponent<BuildingConstruction> ().getConstructionOnGoing ()) {
                        noAttack ();

                        Troop troop = new Troop (selectedUnits.units);

                        foreach (var unit in troop.units) {
                            Construct scriptConstruct = unit.GetComponent<Construct> ();

                            if (scriptConstruct != null) {

                                if (scriptConstruct.getConstruct () || scriptConstruct.getInConstruction ()) {
                                    scriptConstruct.setConstruct (false);
                                    scriptConstruct.SetInConstruction (false);
                                    scriptConstruct.getBuildingToConstruct ().GetComponentOrEnd<BuildingConstruction> ().deleteUnit (unit);
                                }

                                scriptConstruct.SetBuildingToConstruct (hitInfo.transform.gameObject);
                            }
                        }

                        buildingConstruction (hitInfo.transform.gameObject.transform.position, troop);

                    } else {

                        Identity identity = hitInfo.transform.GetComponent<Identity> ();
                        if (identity != null && identity.unitType.isBuilding ()) {

                            // We hit a building
                            moveUnits (identity.gameObject);
                        } else {

                            // We hit the ground
                            noAttack ();
                            target = Instantiate (targetPrefab, hitInfo.point, Quaternion.identity) as GameObject;
                            target.transform.SetParent (targetsParent.transform);
                            moveUnits (target);
                        }
                    }
                } else {
                    // Debug.Log("No hit");
                }
            }
        }

        //End of click
        if (Input.GetMouseButtonUp (0)) {

            if (isSelecting) {
                isSelecting = false;

                //We impose a size of 5 to detect a box.
                //Box Selection
                Vector3 maxVector = new Vector3 (Input.mousePosition.x, Mathf.Max (Input.mousePosition.y, UIheight * Screen.height), Input.mousePosition.z);
                if ((mPos - maxVector).magnitude > 5) {
                    var camera = Camera.main;
                    var viewportBounds = RectDrawer.GetViewportBounds (camera, mPos, maxVector);

                    //Deselecting
                    if (!Input.GetKey (KeyCode.LeftControl))
                        ClearSelection ();

                    //Selecting
                    foreach (var unit in FindObjectsOfType<GameObject>()) {
                        //Units inside the rect get selected.
                        if (viewportBounds.Contains (camera.WorldToViewportPoint (unit.transform.position)) & unit.tag == "Ally" & !selectedUnits.units.Contains (unit)) {
                            selectedUnits.units.Add (unit);
                            Transform projector = unit.transform.FindChild ("Selected");
                            if (projector != null)
                                projector.gameObject.SetActive (true);
                        }

                    }
                    if (selectedUnits.units.Count > 0)
                        selectedUnits.FocusedUnit = selectedUnits.units [0];
                    hud.updateSelection (selectedUnits);
                }
            }

        }

        for (int i = 0; i < 10; ++i) {
            if (Input.GetKey ("" + i)) {
                if (Input.GetKey (KeyCode.LeftAlt)) {
                    troops [i].units.Clear ();
                    foreach (var unit in selectedUnits.units) {
                        troops [i].units.Add (unit);
                    }
                    print (troops [i].units [0]);
                } else {
                    if (troops [i].units.Count > 0) {
                        ClearSelection ();
                        foreach (var unit in troops[i].units) {
                            selectedUnits.units.Add (unit);
                            Transform projector = unit.transform.FindChild ("Selected");
                            if (projector != null)
                                projector.gameObject.SetActive (true);
                        }
                        if (selectedUnits.units.Count > 0)
                            selectedUnits.FocusedUnit = selectedUnits.units [0];
                        hud.updateSelection (selectedUnits);
                    }
                }
            }
        }

        if (Input.GetKeyDown (KeyCode.Tab)) {
            selectedUnits.focusNext ();
            hud.updateSelection (selectedUnits); // There will exist an updateFocus method
        }

        if (Input.GetKeyDown (KeyCode.B)) {
            //createCubeTestingGrid();
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            GameObject target = Instantiate(targetPrefab, selectedUnits.units[0].transform.position, Quaternion.identity) as GameObject;
            if (triangleFormation == true)
            {
                moveUnitsSquare(target);
                triangleFormation = false;
            } else
            {
                moveUnitsTriangle(target);
                triangleFormation = true;
            }
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            GameObject target = Instantiate(targetPrefab, selectedUnits.units[0].transform.position, Quaternion.identity) as GameObject;

        }

        if (Input.GetKeyDown (KeyCode.K)) {
            if (selectedUnits.FocusedUnit != null)
                selectedUnits.FocusedUnit.GetComponent<AttackController> ().attack (selectedUnits.FocusedUnit);
        }

        if (Input.GetKeyDown (KeyCode.I))
            hud.AIPanel.SetActive (! hud.AIPanel.activeSelf);

        if (Input.GetKeyDown (KeyCode.Plus)) {

            nivelMusic += 0.1f;
            AudioListener.volume = nivelMusic;
        }

        if (Input.GetKeyDown (KeyCode.Minus)) {

            nivelMusic -= 0.1f;
            AudioListener.volume = nivelMusic;
        }
    }
Beispiel #56
0
 public virtual void TroopReleaseCaptive(Troop troop, PersonList personlist)
 {
 }
Beispiel #57
0
    public void buildingConstruction(Vector3 position, Troop t)
    {
        placing = false;
        //Debug.Log("tag dintre building construction" + t.units[0].GetComponent<Construct>().getBuildingToConstruct().tag);

        //LOSEntity fow = t.units[0].GetComponent<Construct>().getBuildingToConstruct().GetComponent<LOSEntity>();
        //if (fow != null) fow.IsRevealer = false;

        Construct c;
        foreach (var unit in t.units)
        {
            c = unit.GetComponent<Construct>();
            if (c != null){
                if (unit.tag != c.getBuildingToConstruct().tag)
                    t.units.Remove(unit);
            }
            else
            {
                t.units.Remove(unit);
            }
        }

        //Move the units that are selected to construct to the building position
        GameObject target = Instantiate(targetPrefab, position, Quaternion.identity) as GameObject;
        target.transform.SetParent(targetsParent.transform);
        moveUnits(target, t);

        //Order that the unit has to construct
        foreach (var unit in t.units) unit.GetComponent<Construct>().setConstruct(true);

        enabled = true;//Enable the script
    }
Beispiel #58
0
 public virtual void TroopResistStratagem(Troop sending, Troop receiving, Stratagem stratagem, bool isHarmful)
 {
 }
Beispiel #59
0
 public void noAttack()
 {
     Troop troop = new Troop(selectedUnits.units);
     if (troop.units.Count != 0)
     {
         AttackController atkController;
         foreach (var unit in troop.units)
         {
             atkController = unit.GetComponent<AttackController>();
             if (atkController != null)
             {
                 atkController.attacking_enemy = null;
                 atkController.attacking_target = null;
             }
         }
     }
 }
Beispiel #60
0
 public virtual void TroopRout(Troop sending, Troop receiving)
 {
 }