Example #1
0
    public static AvatarIcon GetAvatarIcon(int avatarID)
    {
        AvatarIcon myAvatar = AvatarIcon.NotSelected;

        if (avatarID == -1)
        {
            myAvatar = AvatarIcon.NotSelected;
        }
        else if (avatarID == 0)
        {
            myAvatar = AvatarIcon.Zebra;
        }
        else if (avatarID == 1)
        {
            myAvatar = AvatarIcon.Rhino;
        }
        else if (avatarID == 2)
        {
            myAvatar = AvatarIcon.Tiger;
        }
        else if (avatarID == 3)
        {
            myAvatar = AvatarIcon.Cassowary;
        }

        return(myAvatar);
    }
Example #2
0
    public void SetPlayerAvatarHUD(AvatarIcon type)
    {
        switch (type)
        {
        case AvatarIcon.Rhino:
            bombLeftStyle   = rhinoBomb;
            avatarIconStyle = avatarRhino;
            plantBombStyle.normal.background = plantRhino;
            break;

        case AvatarIcon.Zebra:
            bombLeftStyle   = zebraBomb;
            avatarIconStyle = avatarZebra;
            plantBombStyle.normal.background = plantZebra;
            break;

        case AvatarIcon.Tiger:
            bombLeftStyle   = tigerBomb;
            avatarIconStyle = avatarTiger;
            plantBombStyle.normal.background = plantTiger;
            break;

        case AvatarIcon.Cassowary:
            bombLeftStyle   = birdBomb;
            avatarIconStyle = avatarBird;
            plantBombStyle.normal.background = plantBird;
            break;
        }
    }
Example #3
0
    public Avatar(long playerID, int avatarID, string playerName)
    {
        this.playerID = playerID;
        this.avatarID = avatarID;
        this.playerName = playerName;

        this.avatarType = GetAvatarIcon(avatarID);
    }
Example #4
0
    public Avatar(long playerID, int avatarID, string playerName)
    {
        this.playerID   = playerID;
        this.avatarID   = avatarID;
        this.playerName = playerName;

        this.avatarType = GetAvatarIcon(avatarID);
    }
    public void InitAvatarHUD(AvatarIcon avatarType, long playerID)
    {
        GameObject hud = GameObject.Find("UnityHUDPrefab");

        if (hud)
        {
            HUD hudScript = hud.GetComponent <HUD>();
            hudScript.SetPlayerAvatarHUD(avatarType);

            hudScript.SetPlayerID(playerID);
        }
    }
    public void UpdateAvatar(int avatarID, long playerID, AvatarIcon avatarType, string playerName)
    {
        tk2dTextMesh nameScript   = null;
        tk2dSprite   avatarScript = null;

        //int selectedAvatar = Avatar
        switch (avatarType)
        {
        // If server returns avatarID of -1
        case AvatarIcon.NotSelected:
            return;

            break;

        case AvatarIcon.Zebra:
            nameScript   = m_AvatarItem1.transform.Find("Name").gameObject.GetComponent <tk2dTextMesh>();
            avatarScript = m_AvatarItem1.transform.Find("Portrait").gameObject.GetComponent <tk2dSprite>();
            m_AvatarItem1.GetComponent <AvatarButton>().enabled = false;
            break;

        case AvatarIcon.Rhino:
            nameScript   = m_AvatarItem2.transform.Find("Name").gameObject.GetComponent <tk2dTextMesh>();
            avatarScript = m_AvatarItem2.transform.Find("Portrait").gameObject.GetComponent <tk2dSprite>();
            m_AvatarItem2.GetComponent <AvatarButton>().enabled = false;
            break;

        case AvatarIcon.Tiger:
            nameScript   = m_AvatarItem3.transform.Find("Name").gameObject.GetComponent <tk2dTextMesh>();
            avatarScript = m_AvatarItem3.transform.Find("Portrait").gameObject.GetComponent <tk2dSprite>();
            m_AvatarItem3.GetComponent <AvatarButton>().enabled = false;
            break;

        case AvatarIcon.Cassowary:
            nameScript   = m_AvatarItem4.transform.Find("Name").gameObject.GetComponent <tk2dTextMesh>();
            avatarScript = m_AvatarItem4.transform.Find("Portrait").gameObject.GetComponent <tk2dSprite>();
            m_AvatarItem4.GetComponent <AvatarButton>().enabled = false;
            break;
        }

        // If they are selected, set the alpha to not so transparent
        if (nameScript)
        {
            nameScript.color = new Color(1.0f, 1.0f, 1.0f, 0.2f);
        }

        if (avatarScript)
        {
            avatarScript.color = new Color(1.0f, 1.0f, 1.0f, 0.2f);
        }
    }
Example #7
0
        public CharacterSerializable Serialize()
        {
            var serializable = new CharacterSerializable();

            serializable.Id         = ItemId.Id;
            serializable.FileName   = ItemId.Name;
            serializable.ItemType   = (int)ItemType.Character;
            serializable.Name       = Name;
            serializable.AvatarIcon = AvatarIcon.ToString();
            serializable.Faction    = Faction.Id;
            serializable.Inventory  = Inventory.Id;
            serializable.Fleet      = Fleet.Id;
            serializable.Relations  = Relations.Value;
            serializable.IsUnique   = IsUnique;
            return(serializable);
        }
    public void InitAvatarHUD(AvatarIcon avatarType, long playerID)
    {
        GameObject hud = GameObject.Find ("UnityHUDPrefab");
        if(hud)
        {
            HUD hudScript = hud.GetComponent<HUD>();
            hudScript.SetPlayerAvatarHUD(avatarType);

            hudScript.SetPlayerID(playerID);
        }
    }
Example #9
0
    public void SetPlayerAvatarHUD(AvatarIcon type)
    {
        switch(type)
        {
            case AvatarIcon.Rhino:
            bombLeftStyle = rhinoBomb;
            avatarIconStyle = avatarRhino;
            plantBombStyle.normal.background = plantRhino;
            break;

            case AvatarIcon.Zebra:
            bombLeftStyle = zebraBomb;
            avatarIconStyle = avatarZebra;
            plantBombStyle.normal.background = plantZebra;
            break;

            case AvatarIcon.Tiger:
            bombLeftStyle = tigerBomb;
            avatarIconStyle = avatarTiger;
            plantBombStyle.normal.background = plantTiger;
            break;

            case AvatarIcon.Cassowary:
            bombLeftStyle = birdBomb;
            avatarIconStyle = avatarBird;
            plantBombStyle.normal.background = plantBird;
            break;
        }
    }
    public void InitCharacter(long playerID, int avatarID, int cellX, int cellY, long serverDelay, string playerName)
    {
        AvatarIcon avatarType = Avatar.GetAvatarIcon(avatarID);

        float localLagDelay = (float)2 * serverDelay / 1000;

        // If it is the player
        if (playerID == GameManager.PlayerID)
        {
            switch (avatarType)
            {
            case AvatarIcon.Rhino:
                playerScript.InitRhinoCharacter(playerID, playerName, cellX, cellY);
                break;


            case AvatarIcon.Zebra:
                playerScript.InitZebraCharacter(playerID, playerName, cellX, cellY);
                break;

            case AvatarIcon.Tiger:
                playerScript.InitTigerCharacter(playerID, playerName, cellX, cellY);
                break;

            case AvatarIcon.Cassowary:
                playerScript.InitBirdCharacter(playerID, playerName, cellX, cellY);
                break;
            }

            InitAvatarHUD(avatarType, playerID);
        }
        // It is the enemy
        else
        {
            var enemyGameObj = Instantiate(enemyGameObject, transform.position, transform.rotation) as GameObject;
            var enemyScript  = enemyGameObj.GetComponent <Player>();
            switch (avatarType)
            {
            // rhino
            case AvatarIcon.Rhino:
                enemyScript.InitRhinoCharacter(playerID, playerName, cellX, cellY);
                break;

            // zebra
            case AvatarIcon.Zebra:
                enemyScript.InitZebraCharacter(playerID, playerName, cellX, cellY);
                break;

            // tiger
            case AvatarIcon.Tiger:
                enemyScript.InitTigerCharacter(playerID, playerName, cellX, cellY);
                break;

            // bird
            case AvatarIcon.Cassowary:
                enemyScript.InitBirdCharacter(playerID, playerName, cellX, cellY);
                break;
            }
        }

        playerList.Add(new Player(playerID, avatarID));
    }
    public void UpdateAvatar(int avatarID, long playerID, AvatarIcon avatarType, string playerName)
    {
        tk2dTextMesh nameScript = null;
        tk2dSprite avatarScript = null;

        //int selectedAvatar = Avatar
        switch(avatarType)
        {
            // If server returns avatarID of -1
            case AvatarIcon.NotSelected:
            return;
            break;

            case AvatarIcon.Zebra:
            nameScript = m_AvatarItem1.transform.Find ("Name").gameObject.GetComponent<tk2dTextMesh>();
            avatarScript = m_AvatarItem1.transform.Find ("Portrait").gameObject.GetComponent<tk2dSprite>();
            m_AvatarItem1.GetComponent<AvatarButton>().enabled = false;
            break;

            case AvatarIcon.Rhino:
            nameScript = m_AvatarItem2.transform.Find ("Name").gameObject.GetComponent<tk2dTextMesh>();
            avatarScript = m_AvatarItem2.transform.Find ("Portrait").gameObject.GetComponent<tk2dSprite>();
            m_AvatarItem2.GetComponent<AvatarButton>().enabled = false;
            break;

            case AvatarIcon.Tiger:
            nameScript = m_AvatarItem3.transform.Find ("Name").gameObject.GetComponent<tk2dTextMesh>();
            avatarScript = m_AvatarItem3.transform.Find ("Portrait").gameObject.GetComponent<tk2dSprite>();
            m_AvatarItem3.GetComponent<AvatarButton>().enabled = false;
            break;

            case AvatarIcon.Cassowary:
            nameScript = m_AvatarItem4.transform.Find ("Name").gameObject.GetComponent<tk2dTextMesh>();
            avatarScript = m_AvatarItem4.transform.Find ("Portrait").gameObject.GetComponent<tk2dSprite>();
            m_AvatarItem4.GetComponent<AvatarButton>().enabled = false;
            break;
        }

        // If they are selected, set the alpha to not so transparent
        if(nameScript)
            nameScript.color = new Color(1.0f, 1.0f, 1.0f, 0.2f);

        if(avatarScript)
            avatarScript.color = new Color(1.0f, 1.0f, 1.0f, 0.2f);
    }