Example #1
0
    private bool CharacterHas(Collider2D collision)
    {
        CatFishScripts.Artifacts.Artifact   artifact  = collision.GetComponent <UnityArtifact>().Behavior;
        CatFishScripts.Characters.Character character =
            GameObject.Find("Canvas").transform.Find("CharacterIcon").GetComponent <ActivePlayer>().player.GetComponent <UnityCharacter>().Character;
        bool has = false;

        for (int i = 0; i < character.Inventory.Artifacts.Count; i++)
        {
            if (character.Inventory.Artifacts[i].Name == artifact.Name)
            {
                has = true;
            }
        }
        return(has);
    }
Example #2
0
    private void PickUp(Collider2D collision)
    {
        CatFishScripts.Artifacts.Artifact artifact = collision.GetComponent <UnityArtifact>().Behavior;
        var activeObject = GameObject.Find("Canvas").transform.Find("CharacterIcon").GetComponent <ActivePlayer>().player;
        var character    = activeObject.GetComponent <UnityCharacter>().Character;

        if (this.transform.parent.gameObject.name != activeObject.name)
        {
            return;
        }
        if (character.Inventory.Artifacts.Count == 25)
        {
            message.Show("Инвентарь переполнен!!!");
        }
        else
        {
            character.Inventory.AddArtifact(artifact);
            collision.gameObject.GetComponent <SpriteRenderer>().enabled = false;
            collision.enabled = false;
        }
    }