Ejemplo n.º 1
0
    /// <summary>
    /// Moves into a tile, and takes control. Assumes tile is unoccupied.
    /// </summary>
    /// <param name="hexTile"></param>
    public void Sieze(GameObject hexTile)
    {
        HexEntity entity = hexTile.GetComponent <HexEntity>();

        Global.MapFlyWeight.TransferHexOwner(hexTile, Controller);
        entity.UpdateController(Controller);
        entity.army = gameObject;

        //Play the movement sound
        GameObject      AudioObj = GameObject.Find("AudioManagerGame");
        ArbitrarySounds sounds   = AudioObj.GetComponentInChildren <ArbitrarySounds>();

        sounds.OnArmyMove();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Combats another unit. Return true if winning combat, false otherwise
    /// </summary>
    public bool Combat(GameObject otherArmyObject)
    {
        if (otherArmyObject != null)
        {
            ArmyEntity otherArmy  = otherArmyObject.GetComponent <ArmyEntity>();
            List <int> myRolls    = ArmyRoll(true);
            List <int> theirRolls = otherArmy.ArmyRoll(false);
            Debug.Log("My rolls " + myRolls);
            Debug.Log("And theirs " + myRolls);
            //DisplayRolls(myRolls, transform.position, new Vector3(0, 3, 0), 2);
            //DisplayRolls(theirRolls, otherArmyObject.transform.position, new Vector3(0, 3, 0), 2);

            int myDamage = 0, theirDamage = 0;
            for (int i = 0; i < theirRolls.Count && i < myRolls.Count; i++)
            {
                if (myRolls[i] <= theirRolls[i])
                {
                    myDamage++;
                }
                if (myRolls[i] >= theirRolls[i])
                {
                    theirDamage++;
                }
            }

            myDamage    *= PowerPerDamage;
            theirDamage *= PowerPerDamage;
            //DisplayDmg(myDamage, transform.position, new Vector3(0, 2.5f, 0), 2);
            //DisplayDmg(theirDamage, otherArmyObject.transform.position, new Vector3(0, 2.5f, 0), 2);

            Manpower           -= myDamage;
            otherArmy.Manpower -= PowerPerDamage;
            CheckDead();
            otherArmy.CheckDead();
        }

        //Play the movement sound
        GameObject      AudioObj = GameObject.Find("AudioManagerGame");
        ArbitrarySounds sounds   = AudioObj.GetComponentInChildren <ArbitrarySounds>();

        sounds.OnArmyAttack();

        return(otherArmyObject == null);
    }