Пример #1
0
    public void Update()
    {
        if (machine.failedState != null)
        {
            machine.RetryFailedState();
        }

        recountTick--;
        if (recountTick < 0)
        {
            recountTick   = 10;
            blueCount     = livingActors.FindAll(x => x.team == ActorTeam.BLUE).Count;
            blueText.text = "BLUE: " + blueCount.ToString();
            redCount      = livingActors.FindAll(x => x.team == ActorTeam.RED).Count;
            redText.text  = "RED: " + redCount.ToString();
            if (redCount == 0 || blueCount == 0)
            {
                GameState currentState = (GameState)machine.GetActiveState();
                if (currentState == GameState.ACTION)
                {
                    machine.SetState(GameState.INTRO);
                }
            }
        }
    }
Пример #2
0
 public void SetStateRecursive(PartState nextState)
 {
     machine.SetState(nextState);
     if (childPart != null)
     {
         childPart.SetStateRecursive(nextState);
     }
 }
Пример #3
0
    void Awake()
    {
        machine = new BasicMachine <PartState>();
        machine.Initialize(typeof(PartState));
        machine.OnChange = OnChange;
        machine[(int)PartState.ATTACHED].OnEnter   = OnAttach;
        machine[(int)PartState.ATTACHED].CanEnter  = CanSwitch;
        machine[(int)PartState.ALIGNING].OnEnter   = OnAlign;
        machine[(int)PartState.ALIGNING].CanEnter  = CanSwitch;
        machine[(int)PartState.ANIMATING].OnEnter  = OnAnimate;
        machine[(int)PartState.ANIMATING].CanEnter = CanSwitch;
        machine[(int)PartState.HELD].OnEnter       = OnHeld;
        machine[(int)PartState.HELD].CanEnter      = CanSwitch;
        machine[(int)PartState.GLUED].OnEnter      = OnGlued;
        machine[(int)PartState.GLUED].CanEnter     = CanSwitch;
        machine[(int)PartState.LAUNCH].OnEnter     = OnLaunch;
        machine[(int)PartState.LAUNCH].CanEnter    = CanSwitch;
        machine[(int)PartState.DORMANT].OnEnter    = OnDormant;
        machine[(int)PartState.DORMANT].CanEnter   = CanSwitch;
        machine[(int)PartState.GROWING].OnEnter    = OnGrow;
        machine[(int)PartState.GROWING].CanEnter   = CanSwitch;

        thisTransform = this.transform;
        thisRenderer  = this.GetComponent <Renderer>();
        thisBody      = this.GetComponentInParent <ActorBody>();
        bodyParent    = thisTransform.parent;
        handParent    = null;
        limbParent    = parentPart != null ? parentPart.transform : null;
        originalPos   = thisTransform.localPosition;
        originalRot   = thisTransform.localRotation;
        originalScale = thisTransform.localScale;
        if (thisBody != null)
        {
            machine.SetState(PartState.ATTACHED);
        }
        CheckDepth();
    }