Exemple #1
0
 private void actuallyAttack()
 {
     ((Unit)selection.getValue("Unit")).attack((Unit)mouse.getValue("Unit"));
     checkGameOver();
     unselect();
     endTurn();
 }
Exemple #2
0
    private void select()
    {
        if (mouse.isSelected("Selectable"))
        {
            HexPosition.clearSelection("Selectable");
            selection = mouse;
            mouse.select("Selection");
            Unit unit = (Unit)mouse.getValue("Unit");
            selectAttackable(unit);
            switch (unit.Status)
            {
            case Unit.State.MOVE:
                turn = Turn.MOVE;
                break;

            case Unit.State.ATTACK:
                turn = Turn.ATTACK;
                break;

            default:
                print("Error: Action " + ((Unit)mouse.getValue("Unit")).Status + " not implemented.");
                break;
            }
        }
    }
Exemple #3
0
    IEnumerator PerformManeuvers(float delayPerAction)
    {
        for (int i = 0; i < allUnits.Count; i++)
        {
            // do each plane's maneuver
            var unit = allUnits[i];
            var m    = allCommands[unit];

            if (unit.hitPoints > 0)
            {
                Debug.Log("Executing: " + m.id.ToString() + " on " + unit.callsign);
                //m.Execute(ref unit);
                unit.PerformManeuver(m);
                unit.Move();
                unit.StallCheck();
                unit.CrashCheck();

                //ManeuverManager.CrashCheck(ref unit);
                //m.aircraft.Move();


                unit.TriggerAnimation();

                // if plane is in range of another plane... attack!
                bool attacked = false;
                for (int range = 1; range <= 2; range++)
                {
                    HexPosition attackPoint = unit.LookAhead(range);
                    if (attackPoint.containsKey(GameBoard.KEY_UNIT_AIR))
                    {
                        UnitAircraft target = (UnitAircraft)attackPoint.getValue(GameBoard.KEY_UNIT_AIR);
                        Debug.Log(unit.callsign + " fires on " + target.callsign);
                        attacked = true;
                        unit.Attack(target);
                        target.TriggerAnimation();
                    }
                }

                if (attacked)
                {
                    unit.AttackAnimation();
                }
            }
            yield return(new WaitForSeconds(delayPerAction));
        }

        if (phase == GamePhase.MANEUVER)
        {
            AdvancePhase();
        }
    }
Exemple #4
0
    /// <summary>
    /// move the plane ahead
    /// </summary>
    public void Move()
    {
        HexPosition newPos = ProjectAhead();

        // crash?
        if (newPos.containsKey(GameBoard.KEY_UNIT_AIR))
        {
            UnitAircraft other = (UnitAircraft)newPos.getValue(GameBoard.KEY_UNIT_AIR);
            if (other != this)
            {
                other.Die("Mid-air collision with " + callsign);
                UpdatePositionTo(newPos);
                Die("Mid-air collision with " + other.callsign);
            }
        }
        else
        {
            UpdatePositionTo(newPos);
        }
    }