コード例 #1
0
    void AttackUnit(Unit enemy)
    {
        int actualAttackValue;

        if (ammo > 0)
        {
            actualAttackValue = attack;
        }
        else
        {
            actualAttackValue = attack / 2;
        }

        readyToAttack = false;
        float rawDamage    = (((actualAttackValue * attackMultiplier) / 100f) + Random.Range(0, 9)) * (hp / 10f) * ((200f - (enemy.defenseMultiplier + enemy.originTile.typeOfTerrain.defensiveStat * enemy.hp)) / 100f);
        int   actualDamage = (int)rawDamage / 10;

        enemy.ChangeHP(-actualDamage);
        propietary.AddPower((int)((enemy.moneyValue / 10) * actualDamage) / 2);
        enemy.propietary.AddPower((int)(enemy.moneyValue / 10) * actualDamage);
        ammo--;

        //Counter
        if (ranged == false && enemy != null && enemy.ranged == false)
        {
            if (enemy.ammo > 0)
            {
                actualAttackValue = enemy.attack;
            }
            else
            {
                actualAttackValue = enemy.attack / 2;
            }

            rawDamage    = (((actualAttackValue * enemy.attackMultiplier) / 100f) + Random.Range(0, 9)) * (enemy.hp / 10f) * ((200f - (defenseMultiplier + originTile.typeOfTerrain.defensiveStat * hp)) / 100f);
            actualDamage = (int)rawDamage / 10;
            ChangeHP(-actualDamage);
            propietary.AddPower((int)(moneyValue / 10) * actualDamage);
            enemy.propietary.AddPower((int)((moneyValue / 10) * actualDamage) / 2);
            enemy.ammo--;
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (gameState == state.NAVIGATING_MENU)
            {
                InGameMenu.inGameMenu.SelectCurrentMenuOption();
            }
            else if (gameState == state.NAVIGATING_FACTORY_MENU)
            {
                FactoryMenu.instance.SelectCurrentMenuOption();
            }
            else if (gameState == state.MOVING_CURSOR || gameState == state.MOVING_UNIT)
            {
                PlayerCursor.instance.GetCurrentTile();
            }
            else if (gameState == state.SELECTING_OBJECTIVE)
            {
                if (unitSelected.readyToAttack)
                {
                    unitSelected.AttackNow();
                }
                else if (unitSelected.readyToLoad)
                {
                    unitSelected.LoadIntoCargo();
                }
                else
                {
                    Cargo unitCargo = unitSelected.GetComponent <Cargo>();
                    if (unitCargo != null && unitCargo.unloadingUnit)
                    {
                        StartCoroutine(unitCargo.UnloadUnitInTile());
                    }
                }
            }
        }

        //This is a patch for avoiding selecting a tile right as you select an option from the menu
        if (gameState == state.CHECKING_ENEMY_UNIT)
        {
            if (Input.GetKeyUp(KeyCode.Return))
            {
                Map.instance.ReturnTilesToNormal();
                //if (attackingWasSelected == true)
                //{
                //	gameState = state.SELECTING_ATTACK;
                //} else
                //{
                gameState = state.MOVING_CURSOR;
                //}
            }
        }
        else if (gameState == state.MOVING_UNIT)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Map.instance.ReturnTilesToNormal();
                gameState = state.MOVING_CURSOR;
            }
        }

        /////////////////////////
        if (Input.GetKeyDown(KeyCode.Space))
        {
            activePlayer.AddPower(2000);
        }
        /////////////////////////
    }