Ejemplo n.º 1
0
    /*void Setup (GameObject oldExp = null) {
     *      BaseSetup ();
     *      if (oldExp != null) {
     *              transform.name = sRend.name.Substring (0, sRend.name.Length - 7) + id.ToString ();
     *              id = oldExp.GetComponent<Experiment> ().id;
     *      } else {
     *              id = -1;
     *      }
     * }*/

    internal void Update()
    {
        if (currentAct != null && !currentAct.Update())
        {
            currentAct = null;
        }

        switch (state)
        {
        case ExpState.Moving:
            //print ("I am : " + expGroup);
            aState = AnimState.Neutral;
            if (expGroup == Society.JOINING_GROUP_ID)
            {
                currentAct = new TeleportToAction(this, society.GetGroupStats(expGroup).GetExpSpot(this));
                SetState(ExpState.Editing);
                break;
            }
            if (expGroup == Society.ROGUE_GROUP_ID)
            {
                currentAct = new MoveToGroupAction(this, society.AvoidGroups(this));
            }
            else
            {
                currentAct = new MoveToGroupAction(this, society.GetGroupStats(expGroup).GetExpSpot(this));
            }
            SetState(ExpState.Pending);
            break;

        case ExpState.Attacking:
            aState = AnimState.Angry;
            if (expGroup < Society.NUM_EXTRA_GROUPS)
            {
                currentAct = new AttackGroupAction(this, society.COMOfGroup(expGroup));
            }
            else
            {
                currentAct = new AttackGroupAction(this, society.GetGroupStats(expGroup).center);
            }
            SetState(ExpState.Pending);
            break;

        case ExpState.Death:
            DestroySelf();
            break;
        }

        UpdateAnimator();
    }