Beispiel #1
0
        static void Main(string[] args)
        {
            LogWriter.WriteLine("[GoatSplitter] Launched");
            goatState = new GoatState();

            // Hook into the split triggers
            goatState.goatTriggers.OnSplit += OnSplitTriggered;

            // Hook into the in-game timer updates
            goatState.OnTimerFixed   += goatState_OnIGTFixed;
            goatState.OnTimerChanged += goatState_OnIGTChanged;
            goatState.OnTimerUpdated += goatState_OnIGTUpdated;

            new Thread(new ThreadStart(ReceiveCommands)).Start();

            bool hasExited = false;

            var profiler = Stopwatch.StartNew();

            while (!hasExited)
            {
                Update();

                if (profiler.ElapsedMilliseconds >= TARGET_UPDATE_RATE)
                {
                    Debug.WriteLine("Update iteration took too long: " + profiler.ElapsedMilliseconds);
                }

                Thread.Sleep(Math.Max(TARGET_UPDATE_RATE - (int)profiler.ElapsedMilliseconds, 1));
                profiler.Restart();
            }
        }
    public State CreateStateFromEnum(GoatState state)
    {
        switch (state)
        {
        case GoatState.Run:
            return(new RunState(Controller));

        case GoatState.None:
            return(new State(Controller));

        case GoatState.SlowDown:
            return(new SlowDownState(Controller));

        case GoatState.Obstacle:
            return(new ObstacleState(Controller));

        case GoatState.Slide:
            return(new SlideState(Controller));

        case GoatState.Jump:
            return(new JumpState(Controller));

        case GoatState.Yell:
            return(new YellState(Controller));

        case GoatState.Die:
            return(new DeadState(Controller));

        default:
            throw new ArgumentOutOfRangeException(nameof(state), state, null);
        }
    }
 public bool CanChangeState(GoatState newState)
 {
     foreach (var state in AvailableTransitions)
     {
         if (state == newState)
         {
             return(true);
         }
     }
     return(false);
 }
    public void SetState(GoatState state)
    {
        switch (state)
        {
        case GoatState.Run:
            SetNormalState();
            break;

        case GoatState.Jump:
            SetJumpingState();
            break;

        case GoatState.Obstacle:
            SetObstacleGoat();
            break;

        case GoatState.SlowDown:
            SetSlowState();
            break;

        case GoatState.Yell:
            SetNormalState();
            YellEffect.SetActive(true);
            YellEffect.transform.position = new Vector3(transform.position.x + 7.5f, transform.position.y);
            break;

        case GoatState.Die:
            SetDeadGoat();
            break;

        case GoatState.Slide:
            SetSlidingGoat();
            break;

        case GoatState.None:
            SetNormalState();
            break;
        }
    }
Beispiel #5
0
 void Start(){
     State = GoatState.Hanging;
     _heartsCollected = 0;
 }
Beispiel #6
0
    void OnTriggerEnter2D(Collider2D col){

        if( col.gameObject.tag == "ExitTrigger"){
            Debug.Log("HIT Exit Trigger");

            if( State == GoatState.Falling){
                State = GoatState.Saved;

//                LevelManager.Instance.ShowWinScreen();

                EventSystem.Instance.GoatWon.TriggerEvent();
            }
        }

        if( col.gameObject.tag == "DeathTrigger"){
           

            if ( State != GoatState.Dead && !isTimeSlow){
                State = GoatState.Dead;
                Debug.Log("You are dead");

                //AudioManager.instance.playBurnt();

                EventSystem.Instance.GoatDied.TriggerEvent();

                GetComponent<Rigidbody2D>().isKinematic = true;
                GetComponent<SpriteRenderer>().enabled = false;

                deathParticle.transform.position = transform.position;
                deathParticle.Play(false);

//                UnityTimer.Instance.CallAfterDelay(() => {
//                    LevelManager.Instance.ShowDieScreen();
//                }, 1.0f);
            }
        }

        if( col.gameObject.tag == "Collectible"){
            Destroy(col.gameObject);
            //Fire event to EventSystem
            _heartsCollected++;
            EventSystem.Instance.HeartCollected.TriggerEvent(_heartsCollected);

            GetComponent<ParticleSystem>().Play(false);

            //AudioManager.instance.playCollect();
        }

    }
Beispiel #7
0
    public void ReleaseGoat(){
        //Break Hinges
        gameObject.GetComponent<HingeJoint2D>().enabled = false;

        gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.up * 3.0f;
        //gameObject.GetComponent<DistanceJoint2D>().enabled = false;
        //gameObject.GetComponent<Rigidbody2D>().velocity *= 1.5f;

        State = GoatState.Falling;

        EventSystem.Instance.GoatReleased.TriggerEvent();
        //AudioManager.instance.playSheep();
    }