Example #1
0
    void Awake()
    {
        Instance = this;
        machine  = new BasicMachine <GameState>();
        machine.Initialize(typeof(GameState));
        machine[(int)GameState.INTRO].OnEnter     = OnIntro;
        machine[(int)GameState.INTRO].OnExit      = OnIntroExit;
        machine[(int)GameState.SPAWNING].OnEnter  = OnSpawn;
        machine[(int)GameState.SPAWNING].CanEnter = CanSpawn;
        machine[(int)GameState.ACTION].CanEnter   = CanAction;
        machine[(int)GameState.ACTION].OnEnter    = OnAction;
        machine[(int)GameState.ACTION].OnExit     = OnActionExit;

        actionCanvas.SetActive(false);
    }
Example #2
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();
    }