Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        body     = gameObject.GetComponent <Rigidbody2D>();
        animator = transform.GetComponent <Animator>();

        states = new AnimatorStates(animator, new string[] {
            "walk",
            "idle",
            "jump",
            "climb",
            "death",
            "wall_slide"
        });

        leveller = new Leveller(this, LEVEL_MAP);

        states.ChangeState("idle");
    }
Ejemplo n.º 2
0
    protected void TakeDamage(int damage)
    {
        damageTaken += damage;

        foreach (KeyValuePair <int, string> pair in destructStates)
        {
            if (damageTaken >= pair.Key)
            {
                if (pair.Value == "destroy")
                {
                    GameObject.Destroy(this.gameObject);
                    return;
                }

                states.ChangeState(pair.Value);
                break;
            }
        }
    }
Ejemplo n.º 3
0
 void KillPlayer()
 {
     states.ChangeState("death");
     health = 0;
     TogglePlayer(false);
 }