Exemplo n.º 1
0
    /*
     * take the necessary actions by the result: remove losing soldier, call MoveSoldier() ,update new references etc..
     */
    private void HandleMatchResult(MatchStatus result)
    {
        //get the initiator's movement direction:
        //MovementDirections direction = CalculateMovementDirectionByAngle(Mathf.Atan2(-relativePos.y, -relativePos.x) * Mathf.Rad2Deg);

        Debug.Log("Match: after evaluate, before ack");
        Debug.Log("player=" + FocusedPlayer.GetComponent <SC_Soldier>().Type + ", active weapon=" + FocusedPlayer.GetComponent <SC_Soldier>().GetActiveWeapon().name);
        Debug.Log("enemy=" + FocusedEnemy.GetComponent <SC_Soldier>().Type + ", active weapon=" + FocusedEnemy.GetComponent <SC_Soldier>().GetActiveWeapon().name);

        switch (result)
        {
        case MatchStatus.INITIATOR_WON_THE_MATCH:
        case MatchStatus.INITIATOR_REVEALED:
            RemoveSoldier(FocusedEnemy);
            RevealSoldier(FocusedPlayer);
            AnnounceMatchWinner(FocusedPlayer.GetComponent <SC_Soldier>().Team);
            break;

        case MatchStatus.VICTIM_WON_THE_MATCH:
        case MatchStatus.VICTIM_REVEALED:
            RemoveSoldier(FocusedPlayer);
            RevealSoldier(FocusedEnemy);
            AnnounceMatchWinner(FocusedEnemy.GetComponent <SC_Soldier>().Team);
            break;

        case MatchStatus.BOTH_LOST_MATCH:
            RemoveSoldier(FocusedPlayer);
            RemoveSoldier(FocusedEnemy);
            AnnounceMatchWinner(SoldierTeam.NO_TEAM);
            break;

        case MatchStatus.TIE:
            TieBreaker();
            break;

        case MatchStatus.INITIATOR_WON_THE_GAME:
            CallFinishGame(FocusedPlayer);
            break;

        case MatchStatus.VICTIM_WON_THE_GAME:
            CallFinishGame(FocusedEnemy);
            break;
        }
    }
Exemplo n.º 2
0
    public TileStatus GetNextTileStatus()
    {
        //calculate new tile requested
        GameObject tile = objects[TILE_NAME_VAR + nextMoveCoord.x + nextMoveCoord.y];

        //save reference to the opponent for easier access later from the controller:
        FocusedEnemy = tile.GetComponent <SC_Tile>().soldier;

        if (FocusedEnemy != null)
        {
            //next tile is occupied with a soldier
            if (FocusedEnemy.GetComponent <SC_Soldier>().Team != FocusedPlayer.GetComponent <SC_Soldier>().Team)
            {
                return(TileStatus.VALID_OPPONENT);
            }
        }

        return(TileStatus.TRV_TILE);
    }
Exemplo n.º 3
0
    internal string GetCurrentBattleAnimationParameters()
    {
        //get current weapons of the player and enemy in our current battle:
        string playerWeapon = FocusedPlayer.GetComponent <SC_Soldier>().Type.ToString();
        string enemyWeapon  = FocusedEnemy.GetComponent <SC_Soldier>().Type.ToString();

        //fix their naming to be first uppercase letter (to match the animation trigger param names):
        string fixedPlayerWeaponParamName = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(playerWeapon.ToString().ToLower());
        string fixedEnemyWeaponParamName  = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(enemyWeapon.ToString().ToLower());

        //the focused player is set by the initiating team, so if the AI was the initiator,
        //we make sure to swap parameter order for a mirror view of the animationg:
        if (FocusedPlayer.GetComponent <SC_Soldier>().Team == SoldierTeam.PLAYER)
        {
            return(fixedPlayerWeaponParamName + fixedEnemyWeaponParamName);
        }
        else
        {
            return(fixedEnemyWeaponParamName + fixedPlayerWeaponParamName);
        }
    }
Exemplo n.º 4
0
    private void HandleTieAck(string data)
    {
        const int   NEW_WEAPON_KEY_CODE_IDX = 1;
        SoldierType newWeapon = (SoldierType)(int.Parse(data.Substring(NEW_WEAPON_KEY_CODE_IDX)));

        //FocusedEnemy.GetComponent<SC_Soldier>().Type = newWeapon;
        FocusedEnemy.GetComponent <SC_Soldier>().RefreshWeapon(newWeapon, false);
        rivalPickedNewWeapon = true;

        if (iPickedNewWeapon)
        {
            //Debug.Log("HandleTieAck: both players picked new weapons. invoking Match()");
            DisplayTurnIndicator();
            ResetWeaponPicksStatus();
            Match(false);
        }
        else
        {
            //Debug.LogError("i didnt choose a weapon just yet..");
        }
    }
Exemplo n.º 5
0
 private GameObject GetAISoldier()
 {
     return(FocusedEnemy.GetComponent <SC_Soldier>().Team == SoldierTeam.ENEMY ? FocusedEnemy : FocusedPlayer);
 }