Exemplo n.º 1
0
    //Unit Movement mode functions
    void Update_UnitMove()
    {
        if (Input.GetMouseButtonUp(1) && !Input.GetKey(KeyCode.LeftShift) || Selectedunit == null)
        {
            Debug.Log("complete Move");

            if (Selectedunit != null) //&& test.Length <= 0 )
            {
                Selectedunit.setHexPath(Path);

                StartCoroutine(hexGrid.UnitMove(Selectedunit));
            }

            Reset_Mode();
            return;
        }

        if ((Input.GetMouseButtonUp(1) && Input.GetKey(KeyCode.LeftShift)) || Selectedunit == null)
        {
            Debug.Log("complete Move");

            if (Selectedunit != null) //&& test.Length <= 0 )
            {
                SquadMovement(hexUnderMouse);
                StartCoroutine(hexGrid.GroupMovement(selectedSquad));
            }

            Reset_Mode();
            return;
        }

        if (Path == null || hexUnderMouse != hexPrevious)
        {
            Path = QPath.QPath.FindPath <Hex>(hexGrid, Selectedunit, Selectedunit.Hex, hexUnderMouse, Hex.CostEstimate);
        }
    }
Exemplo n.º 2
0
    //Unit Fire mode functions
    void Update_Fire()
    {
        if ((Input.GetMouseButtonUp(1) && !Input.GetKey(KeyCode.LeftShift)) || Selectedunit == null || TargetUnit == null)
        {
            Debug.Log("complete Move");

            if (Selectedunit != null && TargetUnit != null && Hex.Distance(Selectedunit.Hex, TargetUnit.Hex) < Selectedunit.weapons[1].range)
            {
                int damage = Selectedunit.Fire(TargetUnit, false, Selectedunit.weapons[1]);
                dmgLog.Add(new DamageLogEntry(TargetUnit.name, Selectedunit.name, damage.ToString(), hexGrid.turnNum.ToString(), hexGrid.currentPhase, false, Selectedunit.weapons[1].type));
                TargetUnit.damageTaken(damage);
                Debug.Log("Unit " + TargetUnit.name + " took " + damage + "damage");
                DeathCheck(TargetUnit);

                /*
                 * if (TargetUnit.WoundsRem <= 0)
                 * {
                 *
                 *  Hex DeathSpot = TargetUnit.Hex;
                 *  GameObject GO = hexGrid.GetUnitGO(TargetUnit);
                 *  GO.SetActive(false);
                 *  DeathSpot.RemoveUnit(TargetUnit);
                 *
                 * should be in melee
                 *  if (Selectedunit.movesRem>0)
                 *  {
                 *      Hex[] deathRoute = QPath.QPath.FindPath<Hex>(hexGrid, Selectedunit, Selectedunit.Hex, DeathSpot, Hex.CostEstimate);
                 *      Selectedunit.setHexPath(deathRoute);
                 *      StartCoroutine(hexGrid.UnitMove(Selectedunit));
                 *  }
                 * }*/
            }


            else if (Hex.Distance(Selectedunit.Hex, TargetUnit.Hex) > Selectedunit.weapons[1].range)
            {
                Debug.Log("Too far away from target");
            }

            Reset_Mode();

            return;
        }

        if ((Input.GetMouseButtonUp(1) && Input.GetKey(KeyCode.LeftShift)) || Selectedunit == null || TargetUnit == null)
        {
            Debug.Log("complete Move");

            if (Selectedunit != null && TargetUnit != null && Hex.Distance(Selectedunit.Hex, TargetUnit.Hex) < Selectedunit.weapons[1].range)
            {
                squadFire(selectedSquad, targetSquad, false);
            }


            else if (Hex.Distance(Selectedunit.Hex, TargetUnit.Hex) > Selectedunit.weapons[1].range)
            {
                Debug.Log("Too far away from target");
            }

            Reset_Mode();

            return;
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        if (hexGrid.CurrentT.Name != "AI")
        {
            SelectionBoxes();
        }

        if (hexGrid.currentPhase == HexGrid.Phase.Movement && hexGrid.CurrentT.Name != "AI")
        {
            RangeRender();
            Fought = false;
        }

        if (GameOver == false)
        {
            hexUnderMouse = MouseToHex();

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Reset_Mode();
                Selectedunit = null;
            }

            Update_CurrentFunction();
            Update_ScrollControl();

            lastMousePos = Input.mousePosition;

            hexPrevious = hexUnderMouse;

            if (Selectedunit != null)
            {
                pathVisual((Path != null) ? Path : Selectedunit.HexQueue());
                //Debug.Log(Selectedunit.name.ToString());
            }

            else if (Selectedunit == null)
            {
                pathVisual(null);
            }

            if (Input.GetKeyDown(KeyCode.M))
            {
                hexGrid.endTurn();
            }

            if (hexGrid.currentPhase == HexGrid.Phase.Fight &&
                MoveHappening == false &&
                Fireing == false &&
                Chargeing == false &&
                Fighting == false &&
                hexGrid.animOn == false)
            {
                if (Fought != true)
                {
                    StartCoroutine(FightPhase());
                    Debug.Log("Should only run once");
                }
            }

            if (
                hexGrid.CurrentT.Name == "AI" &&
                MoveHappening == false &&
                Fireing == false &&
                Chargeing == false &&
                Fighting == false &&
                hexGrid.animOn == false &&
                hexGrid.currentPhase != HexGrid.Phase.Fight)
            {
                //Debug.Log(hexGrid.animOn);
                switch (hexGrid.currentPhase)
                {
                case HexGrid.Phase.Movement:
                    StartCoroutine(AIMove());
                    Reset_Mode();
                    break;

                case HexGrid.Phase.Fire:
                    StartCoroutine(AIFire());
                    Reset_Mode();
                    break;

                case HexGrid.Phase.Charge:
                    StartCoroutine(AICharge());
                    Reset_Mode();
                    break;
                }
            }
        }
    }