Exemplo n.º 1
0
    private Animation searchForAnim(Entity.Direction dir, Entity.Action act)
    {
        //remove 1 since dir starts with NONE, which is actually never used for the animation
        int tryPos = 4 * (int)act + (int)dir - 1;

        if (tryPos < states.Count)
        {
            Animation a = states[tryPos];
            if (a.direction == dir && a.action == act)
            {
                //this is a standard list !
                return(a);
            }
        }

        foreach (Animation a in states)
        {
            if (a.direction == dir && a.action == act)
            {
                return(a);
            }
        }


        throw new KeyNotFoundException("Unable to find an animation for this combination of states:(" + dir + ", " + act + ")");
    }
Exemplo n.º 2
0
    //private Entity.Type projectileOwner;

    public void Initialize(string ownerTag, Entity.Direction direction, float dmg, float force = 100f)
    {
        projectileOwner = ownerTag;
        damage          = dmg;
        projectileForce = force;
        if (direction == Entity.Direction.Left)
        {
            //this.GetComponent<SpriteRenderer>().flipX = true;
            this.transform.localScale = new Vector3(-1, 1, 1);
            xDir = -1;
        }
    }
Exemplo n.º 3
0
    public void changeAnimState(Entity.Direction dir, Entity.Action act)
    {
        if (currentSate.direction == dir && currentSate.action == act)
        {
            //no need to update if we are already in the current state
            return;
        }

        try
        {
            currentSate = searchForAnim(dir, act);
        }
        catch (KeyNotFoundException e)
        {
            Debug.Log(e.StackTrace);
            currentSate = states[0];
        }


        anim.Play(currentSate.animationName);
    }