Ejemplo n.º 1
0
 public override void Update()
 {
     base.Update();
     if (((MyMatchVariants)Level.Session.MatchSettings.Variants).CrownSummonsChaliceGhost)
     {
         if (lastHatState == "UNSET")
         {
             lastHatState = HatState.ToString();
         }
         else if (lastHatState != HatState.ToString())
         {
             if (lastHatState != "Crown" && HatState.ToString() == "Crown")
             {
                 MyChalicePad chalicePad = new MyChalicePad(ActualPosition, 4);
                 MyChalice    chalice    = new MyChalice(chalicePad);
                 summonedChaliceGhost = new MyChaliceGhost(
                     PlayerIndex,
                     chalice,
                     ((MyMatchVariants)Level.Session.MatchSettings.Variants).ChaliceGhostsHuntGhosts
                     );
                 Level.Layers[summonedChaliceGhost.LayerIndex].Add(summonedChaliceGhost, false);
             }
             else if (summonedChaliceGhost && lastHatState == "Crown" && HatState.ToString() != "Crown")
             {
                 // Ghost vanishes when player loses the crown
                 summonedChaliceGhost.Vanish();
                 summonedChaliceGhost = null;
             }
             lastHatState = HatState.ToString();
         }
     }
 }
Ejemplo n.º 2
0
    // Use this for initialization
    void Awake()
    {
        if (StaticRef == null) // if theres is not allerdaye a static ref makes this the static ref
        {
            DontDestroyOnLoad(gameObject);
            StaticRef = this;
        }
        else if (StaticRef != this) // is the allready is a ref , destory this
        {
            Destroy(this);
        }

        player = GameController_script.playerRef;

        sphereRadius = this.GetComponent <SphereCollider>();

        hat = GameObject.FindGameObjectWithTag("hat").transform;

        book = GameObject.FindGameObjectWithTag("book").transform;

        book_anim = book.GetComponentInChildren <Animator>();

        hat.gameObject.SetActive(true);

        book.gameObject.SetActive(false);

        haveHat = HatState.Yes;

        hatSpwanTarget = GameObject.FindGameObjectWithTag("hatSpawn").transform;
    }
Ejemplo n.º 3
0
 public static NativeHatState ToNativeHatState(HatState s)
 {
     if (toNative.TryGetValue(s, out NativeHatState ns))
     {
         return(ns);
     }
     return(NativeHatState.Center);
 }
Ejemplo n.º 4
0
        private IEnumerator FlipHatIENum()
        {
            RollLength   = hatOwner.rollStats.GetModifiedTime(hatOwner);
            currentState = HatState.FLIPPING;
            yield return(new WaitForSecondsRealtime(RollLength));

            currentState = HatState.SITTING;
            StickHatToPlayer(hatOwner);
        }
        public void InputHat(HatState hatState)
        {
            if (!Available())
            {
                return;
            }

            var stream = client.GetStream();

            byte[] data = new byte[1];
            data[0] = (byte)(0xe0 | ((byte)HatStateUtil.ToNativeHatState(hatState)));

            stream.Write(data, 0, data.Length);
        }
Ejemplo n.º 6
0
        public void StickHatToPlayer(PlayerController player)
        {
            if (hatOwner == null)
            {
                hatOwner = player;
            }
            Vector2 vec = GetHatPosition(player);

            base.transform.position = vec;
            base.transform.rotation = Quaternion.Euler(0, 0, 0);
            base.transform.parent   = player.transform;
            player.sprite.AttachRenderer(gameObject.GetComponent <tk2dBaseSprite>());
            currentState = HatState.SITTING;
        }
Ejemplo n.º 7
0
    // Use this for initialization
    void Awake()
    {
        if (StaticRef == null) // if theres is not allerdaye a static ref makes this the static ref
        {
            DontDestroyOnLoad(gameObject);
            StaticRef = this;
        }
        else if (StaticRef != this) // is the allready is a ref , destory this
        {
            Destroy(this);
        }

        player = GameController_script.playerRef;

        sphereRadius = this.GetComponent<SphereCollider>();

        hat = GameObject.FindGameObjectWithTag("hat").transform;

        book = GameObject.FindGameObjectWithTag("book").transform;

        book_anim = book.GetComponentInChildren<Animator>();

        hat.gameObject.SetActive(true);

        book.gameObject.SetActive(false);

        haveHat = HatState.Yes;

        hatSpwanTarget = GameObject.FindGameObjectWithTag("hatSpawn").transform;
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        eventTimer = eventTimer - Time.deltaTime;

        if(GameController_script.animRef != null)
        {

            if (eventTimer <= 0)
            {

                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventOne") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventTwo") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventThree") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventFour"))
                {
                    // Debug.Log("event animtion playing");
                    GameController_script.animRef.SetBool("IsWalking", false);
                    GameController_script.animRef.SetBool("IsRunning", false);
                }

                //      if (!anim.GetCurrentAnimatorStateInfo(0).IsName("eventOne") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventTwo") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventThree") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventFour"))
                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f)
                {
                    // Debug.Log("event animtion NOT playing");
                    charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;

                }

                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventThree") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.80f)
                {

                    if (haveHat == HatState.Yes)
                    {
                        Debug.Log(GameController_script.StaticRef.currentScenario);

                        if (GameController_script.StaticRef.currentScenario == GameController_script.scenario.scenario_C)
                        {
                            flyingHat = SpwanHat(flyingHatPrefab_C);
                            eventTimer = 1;
                        }

                        if (GameController_script.StaticRef.currentScenario == GameController_script.scenario.scenario_R)
                        {
                            flyingHat = SpwanHat(flyingHatPrefab_R);
                            eventTimer = 1;
                        }

                        hat_anim = flyingHat.GetComponentInChildren<Animator>();

                        haveHat = HatState.No; // removeing this. spwan loads of hats. could be a funny outtake clip
                        hat.gameObject.SetActive(false);
                        GameController_script.animRef.SetBool("haveHat", false);

                    }
                }
            }
        }

        if (haveHat == HatState.PickingUp )
        {
            Debug.Log("in pickup state");

            charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.inCutScreen;

            GameController_script.animRef.Play("PickUp");
            hat_anim.Play("PickedUp");

            if (hat_anim.GetCurrentAnimatorStateInfo(0).IsName("PickedUp") && hat_anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.87f)
            {

                Destroy(flyingHat, 0f);
                haveHat = HatState.Yes;
                hat.gameObject.SetActive(true);
                GameController_script.animRef.SetBool("haveHat", true);

                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;

            }

        }

        if (GameController_script.animRef != null)
        {

            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("open"))
            {
                book.gameObject.SetActive(true);
                book_anim.Play("openBook");
                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.inCutScreen;
            }

            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("open") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f && GameController_script.StaticRef.currentState == GameController_script.State.running)
            {

                GameController_script.StaticRef.mainMenu.alpha = 1;
                GameController_script.StaticRef.mainMenu.blocksRaycasts = true;
                GameController_script.StaticRef.mainMenu.interactable = true;

                Debug.Log("trying to toggle menu after anition open");
                GameController_script.StaticRef.currentState = GameController_script.State.options;
            }

            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("close"))
            {
                book_anim.Play("closeBook");
                GameController_script.StaticRef.mainMenu.alpha = 0;
                GameController_script.StaticRef.mainMenu.blocksRaycasts = false;
                GameController_script.StaticRef.mainMenu.interactable = false;
            }
            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("close") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f && GameController_script.StaticRef.currentState == GameController_script.State.options)
            {

                Debug.Log("trying to toggle menu after anition close");
                GameController_script.StaticRef.currentState = GameController_script.State.running;
                book.gameObject.SetActive(false);
                GameController_script.animRef.Play("idel");
                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;
            }
        }
    }
Ejemplo n.º 9
0
 public static async Task PushHatAsync(this IController c, CancellationToken ctx, HatState s, int delay)
 {
     await c.PushHatTAsync(ctx, s, ButtonDelay, delay);
 }
Ejemplo n.º 10
0
        public static async Task PushHatNAsync(this IController c, CancellationToken ctx, HatState s, int delay, int count)
        {
            if (ctx.IsCancellationRequested)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                await c.PushHatAsync(ctx, s, delay);
            }
        }
Ejemplo n.º 11
0
        public static async Task PushHatTAsync(this IController c, CancellationToken ctx, HatState s, int time, int delay)
        {
            if (ctx.IsCancellationRequested)
            {
                return;
            }

            c.InputHat(s);
            await DelayAsync(ctx, time);

            if (ctx.IsCancellationRequested)
            {
                return;
            }

            c.InputHat(HatState.Center);
            await DelayAsync(ctx, delay);

            if (ctx.IsCancellationRequested)
            {
                return;
            }
        }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        eventTimer = eventTimer - Time.deltaTime;

        if (GameController_script.animRef != null)
        {
            if (eventTimer <= 0)
            {
                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventOne") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventTwo") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventThree") || GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventFour"))
                {
                    // Debug.Log("event animtion playing");
                    GameController_script.animRef.SetBool("IsWalking", false);
                    GameController_script.animRef.SetBool("IsRunning", false);
                }

                //      if (!anim.GetCurrentAnimatorStateInfo(0).IsName("eventOne") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventTwo") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventThree") && !anim.GetCurrentAnimatorStateInfo(0).IsName("eventFour"))
                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f)
                {
                    // Debug.Log("event animtion NOT playing");
                    charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;
                }

                if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("eventThree") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.80f)
                {
                    if (haveHat == HatState.Yes)
                    {
                        Debug.Log(GameController_script.StaticRef.currentScenario);

                        if (GameController_script.StaticRef.currentScenario == GameController_script.scenario.scenario_C)
                        {
                            flyingHat  = SpwanHat(flyingHatPrefab_C);
                            eventTimer = 1;
                        }


                        if (GameController_script.StaticRef.currentScenario == GameController_script.scenario.scenario_R)
                        {
                            flyingHat  = SpwanHat(flyingHatPrefab_R);
                            eventTimer = 1;
                        }

                        hat_anim = flyingHat.GetComponentInChildren <Animator>();

                        haveHat = HatState.No; // removeing this. spwan loads of hats. could be a funny outtake clip
                        hat.gameObject.SetActive(false);
                        GameController_script.animRef.SetBool("haveHat", false);
                    }
                }
            }
        }

        if (haveHat == HatState.PickingUp)
        {
            Debug.Log("in pickup state");

            charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.inCutScreen;

            GameController_script.animRef.Play("PickUp");
            hat_anim.Play("PickedUp");

            if (hat_anim.GetCurrentAnimatorStateInfo(0).IsName("PickedUp") && hat_anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.87f)
            {
                Destroy(flyingHat, 0f);
                haveHat = HatState.Yes;
                hat.gameObject.SetActive(true);
                GameController_script.animRef.SetBool("haveHat", true);

                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;
            }
        }

        if (GameController_script.animRef != null)
        {
            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("open"))
            {
                book.gameObject.SetActive(true);
                book_anim.Play("openBook");
                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.inCutScreen;
            }

            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("open") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f && GameController_script.StaticRef.currentState == GameController_script.State.running)
            {
                GameController_script.StaticRef.mainMenu.alpha          = 1;
                GameController_script.StaticRef.mainMenu.blocksRaycasts = true;
                GameController_script.StaticRef.mainMenu.interactable   = true;

                Debug.Log("trying to toggle menu after anition open");
                GameController_script.StaticRef.currentState = GameController_script.State.options;
            }

            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("close"))
            {
                book_anim.Play("closeBook");
                GameController_script.StaticRef.mainMenu.alpha          = 0;
                GameController_script.StaticRef.mainMenu.blocksRaycasts = false;
                GameController_script.StaticRef.mainMenu.interactable   = false;
            }
            if (GameController_script.animRef.GetCurrentAnimatorStateInfo(0).IsName("close") && GameController_script.animRef.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99f && GameController_script.StaticRef.currentState == GameController_script.State.options)
            {
                Debug.Log("trying to toggle menu after anition close");
                GameController_script.StaticRef.currentState = GameController_script.State.running;
                book.gameObject.SetActive(false);
                GameController_script.animRef.Play("idel");
                charcterMovemnets.StaticRef.CurrentState = charcterMovemnets.State.canMove;
            }
        }
    }
 internal JoystickHatMotionEventArgs(Native.SDL_JoyHatEvent hat) : base(hat.Timestamp)
 {
     Hat   = hat.Hat;
     Value = hat.Value;
 }