Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        switch (meState)
        {
        case KState.WaitingForInput:
            if (UpdateWaitingForInput())
            {
                E_BoxClicked();
            }
            break;

        case KState.Processing:
            if (!UpdateProcessing())
            {
                E_BoxReleased();
            }
            if (IsAllBeaconReady())
            {
                meState = KState.Locked;
                E_StateLocked();
            }
            break;

        case KState.Locked:
            break;
        }
        //if clicked see if any one of the boxs I have are clicked.
        //if mouse down then put the state to dragging
        //check if the dragged box is closer the the point I am planning to have it.
        //if it is close enough then release the box then set it to that position.
    }
Esempio n. 2
0
    ///<summary>ぜんざいを机に置く。神が着席していない/ぜんざいが既にある場合はfalseを返します</summary>
    public bool TryToPutZenzai()
    {
        //神が着席しているがぜんざいが無い状態の時だけ…
        if (KamiState == KState.LackingOfZenzai)
        {
            KamiState   = KState.Eating;
            ZenzaiState = ZState.BeingEaten;

            zenzaiObj.SetActive(true);
            zenzaiObj.GetComponent <SpriteRenderer>().sprite = zenzaiSpr;

            _FramesUntilAteUp = framesToEat;

            for (int k = 0; k < 2; k++)
            {
                fukidashis[k].SetActive(false);
                fukidashis[k].transform.position = new Vector3((k - 1) * 0.7f, (-(System.Math.Abs(k - 1)) + 3) * 0.4f, -2)
                                                   + transform.position;
                fukidashis[k].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0);
            }
            fukidashis[2].SetActive(true);

            audioSource.PlayOneShot(putSE);

            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 3
0
 public void HitEvent()
 {
     visuals.SetBool("Hit", false);
     visuals.SetBool("Attacking", false);
     visuals.SetBool("Moving", false);
     state = KState.Idle;
 }
    public void SetState(KState state)
    {
        switch (state)
        {
        case KState.ClickMe:
            timeelapsed_ClickMeNotify = 0;
            meState = state;
            break;

        case KState.Talking:
        case KState.TalkingFinishing:
            meState = state; break;

        case KState.Disabled:
            if (meState == KState.Talking)
            {
                meState = KState.TalkingFinishing;
            }
            else
            {
                meState = state;
            }
            break;
        }
    }
 void Update()
 {
     switch (meState) {
     case KState.Disabled:
         break;
     case KState.ClickMe:
         timeelapsed_ClickMeNotify+= Time.deltaTime;
         if(timeelapsed_ClickMeNotify > timeElapsed_ClickMeMax ){
             timeelapsed_ClickMeNotify=0;
             E_ClickMeNotify();
         }
         break;
     case KState.Talking:
         this.transform.localRotation = Quaternion.Euler (0, this.transform.localRotation.eulerAngles.y + SPEED_ROTATION * Time.deltaTime, 0);
         break;
     case KState.TalkingFinishing:
         //stopping to pause
         this.transform.localRotation = Quaternion.Euler(
             transform.localRotation.eulerAngles +
             (new Vector3(0,360,0) - transform.localRotation.eulerAngles)* 1f*Time.deltaTime );
         float dis = (new Vector3(0,360,0) - transform.localRotation.eulerAngles).sqrMagnitude;
         if(dis < .01){
             meState = KState.Disabled;
         }
         break;
     }
 }
    void Update()
    {
        switch (meState)
        {
        case KState.Disabled:
            break;

        case KState.ClickMe:
            timeelapsed_ClickMeNotify += Time.deltaTime;
            if (timeelapsed_ClickMeNotify > timeElapsed_ClickMeMax)
            {
                timeelapsed_ClickMeNotify = 0;
                E_ClickMeNotify();
            }
            break;

        case KState.Talking:
            this.transform.localRotation = Quaternion.Euler(0, this.transform.localRotation.eulerAngles.y + SPEED_ROTATION * Time.deltaTime, 0);
            break;

        case KState.TalkingFinishing:
            //stopping to pause
            this.transform.localRotation = Quaternion.Euler(
                transform.localRotation.eulerAngles +
                (new Vector3(0, 360, 0) - transform.localRotation.eulerAngles) * 1f * Time.deltaTime);
            float dis = (new Vector3(0, 360, 0) - transform.localRotation.eulerAngles).sqrMagnitude;
            if (dis < .01)
            {
                meState = KState.Disabled;
            }
            break;
        }
    }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p">The <see cref="Player" /> that has the buff.</param>
        /// <param name="index">The index of the buff.</param>
        public override void Effects(Player p, int index)
        {
            base.Effects(p, index);

            if (--cd < 0)
            {
                cd = 0;
            }

            if (KState.Down(Keys.J) && KState.WasUp(Keys.J) && cd <= 0)
            {
                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }

                p.position = new Vector2(Main.mouseX, Main.mouseY) + Main.screenPosition;

                Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 8);

                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }

                cd = CD_MAX;
            }
        }
Esempio n. 8
0
    ///<summary>完食されたぜんざいを片付ける。ぜんざいが無いもしくは食べている途中の場合はfalseを返します</summary>
    public bool TryToRemoveZenzai()
    {
        //ぜんざい完食済みの時だけ
        if (ZenzaiState == ZState.WasEaten)
        {
            ZenzaiState = ZState.NoZenzai;
            zenzaiObj.SetActive(false);

            FramesUntilGetOut = framesToGetOut;

            //Ate<->lackingOfZenzai間だけはぜんざいの有無によるので…
            if (KamiState == KState.Ate)
            {
                KamiState = KState.LackingOfZenzai;
            }

            audioSource.PlayOneShot(takeSE);

            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 9
0
 public static bool isKeyUp(Keys key)
 {
     if (KState.IsKeyUp(key))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
 public void textInput()
 {
     if (KState.GetPressedKeys().Length > 0)
     {
         foreach (Keys key in KState.GetPressedKeys())
         {
             if (keyPressed(key))
             {
                 int k = (int)key;
                 if (k >= 48 && k <= 57 || k >= 65 && k <= 90 || k >= 96 && k <= 107 || k >= 109 && k <= 111 || k >= 186 && k <= 192 || k >= 219 && k <= 222)
                 {
                     if (isSelect)
                     {
                         text.Remove(firstChar, secondChar - firstChar);
                         isSelect     = false;
                         selectedText = "";
                         caretPos     = firstChar;
                     }
                     if (KState.CapsLock)
                     {
                         if (isKeyDown(Keys.LeftShift) || isKeyDown(Keys.RightShift))
                         {
                             text.Insert(caretPos, getAlterSymbol(key).ToLower());
                             caretPos++;
                         }
                         else
                         {
                             text.Insert(caretPos, getSymbol(key).ToUpper());
                             caretPos++;
                         }
                     }
                     else
                     {
                         if (isKeyDown(Keys.LeftShift) || isKeyDown(Keys.RightShift))
                         {
                             text.Insert(caretPos, getAlterSymbol(key));
                             caretPos++;
                         }
                         else
                         {
                             text.Insert(caretPos, getSymbol(key));
                             caretPos++;
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 11
0
 bool UpdateWaitingForInput()
 {
     if (!Input.GetMouseButtonDown(0))
     {
         return(false);
     }
     boxSelected = GetCollidedBox();
     //boxSelectedPositionInit = boxSelected.transform.position;
     if (boxSelected == null)
     {
         return(false);
     }
     meState = KState.Processing;
     return(true);
 }
 public void Update(GameTime gt)
 {
     for (int i = 0; i < screens.Count(); i++)
     {
         if (screens[i].CurrentStatus != SplashScreen.Status.NotReady)
         {
             screens[i].Update(gt);
             if (KState.Clicked(skipButton))
             {
                 screens[i].End();
             }
             break;
         }
     }
 }
Esempio n. 13
0
 public static bool IsSatisfiedDown(KModifier[] modifiers, ref bool aKeyWasJustPressed)
 {
     for (int i = 0; i < modifiers.Length; ++i)
     {
         KState ks = ((KCode)modifiers[i]).GetState();                //modifiers[i].key.GetState();
         if (ks == KState.KeyReleased)
         {
             return(false);
         }
         if (ks == KState.KeyDown)
         {
             aKeyWasJustPressed = true;
         }
     }
     return(true);
 }
Esempio n. 14
0
 public static bool IsSatisfiedUp(KModifier[] modifiers, ref bool anyKeyIsBeingReleased)
 {
     for (int i = 0; i < modifiers.Length; ++i)
     {
         KState ks = ((KCode)modifiers[i]).GetState();                //modifiers[i].key.GetState();
         if (ks == KState.KeyReleased)
         {
             return(false);
         }
         if (ks == KState.KeyUp)
         {
             anyKeyIsBeingReleased = true;
         }
     }
     return(true);
 }
        /// <summary>
        /// When the <see cref="Player" /> is holding the <see cref="Item" />.
        /// </summary>
        /// <param name="p">The <see cref="Player" /> that is holding the <see cref="Item" />.</param>
        public override void HoldStyle(Player p)
        {
            base.HoldStyle(p);

            if (--tpCd < 0)
            {
                tpCd = 0;
            }
            if (--modeCd < 0)
            {
                modeCd = 0;
            }

            if (Main.mouseRight && Main.mouseRightRelease && modeCd <= 0)
            {
                UseMode++;

                if (UseMode > Mode.Underworld /* 6 */)
                {
                    UseMode = 0;
                }

                Main.NewText("Mode changed: " + UseMode);

                modeCd = MODE_CD_MAX;
            }

            if (KState.Down(AvalonMod.ShadowMirrorHotkey) && KState.WasUp(AvalonMod.ShadowMirrorHotkey) && tpCd <= 0)
            {
                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }

                p.position = new Vector2(Main.mouseX, Main.mouseY) + Main.screenPosition;

                Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 8);

                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }

                tpCd = TP_CD_MAX;
            }
        }
Esempio n. 16
0
 public void SetState(KState state)
 {
     switch (state) {
     case KState.ClickMe:
         timeelapsed_ClickMeNotify = 0;
         meState = state;
         break;
     case KState.Talking:
     case KState.TalkingFinishing:
         meState = state;break;
     case KState.Disabled:
         if(meState == KState.Talking){
             meState = KState.TalkingFinishing;
         }
         else meState = state;
         break;
     }
 }
Esempio n. 17
0
        public bool IsSatisfiedUp()
        {
            KState ks = key.GetState();
            bool   anyKeyIsBeingReleased = ks == KState.KeyUp;

            if (ks == KState.KeyReleased)
            {
                return(false);
            }
            if (modifiers != null)
            {
                if (!IsSatisfiedUp(modifiers, ref anyKeyIsBeingReleased))
                {
                    return(false);
                }
            }
            return(anyKeyIsBeingReleased);
        }
Esempio n. 18
0
 bool UpdateProcessing()
 {
     if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0)
     {
         var pos0 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
         var pos1 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1));
         var pos  = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, POSITION_Z / (pos1.z - pos0.z)));
         boxSelected.Move(boxSelected.transform.position,
                          new Vector3(Mathf.Clamp(pos.x, -10, 10), Mathf.Clamp(pos.y, -1, 10), pos.z), .1f);
         //boxSelected.Move (boxSelected.transform.position, new Vector3(pos.x,pom.y, boxSelected.transform.position.z), .3f);
     }
     if (Input.GetMouseButtonUp(0))
     {
         meState = KState.WaitingForInput;
         int n = GetTouchedBeacon(boxSelected);
         BoxTouchedBeacon(boxSelected, (n == -1)? null: beacons[n]);
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// When the <see cref="Player" /> has the <see cref="Item" /> equipped.
        /// </summary>
        /// <param name="p"></param>
        public override void Effects(Player p)
        {
            base.Effects(p);

            if (KState.Down(AvalonMod.ShadowMirrorHotkey) && KState.WasUp(AvalonMod.ShadowMirrorHotkey) && tpCd <= 0)
            {
                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }

                p.position = new Vector2(Main.mouseX, Main.mouseY) + Main.screenPosition;

                Main.PlaySound(2, (int)p.position.X, (int)p.position.Y, 8);

                for (int i = 0; i < 10; i++)
                {
                    ExtendedSpawning.NewDust(p.Hitbox, 15);
                }
            }
        }
Esempio n. 20
0
        public void TestBreak()
        {
            // Test k-state in case of HMM break 'no transition' as reported in barefoot issue #83.
            // Tests only 'no transitions', no emissions is empty vector and, hence, input to update
            // operation.

            var state    = new KState <MockElem, MockStateTransition, MockSample>();
            var elements = new Dictionary <int, MockElem>();

            elements[0] = new MockElem(0, Math.Log10(0.4), 0.4, null);
            {
                var vector = new HashSet <MockElem>()
                {
                    elements[0]
                };
                state.Update(vector, new MockSample(0));
            }
            elements[1] = new MockElem(1, Math.Log(0.7), 0.6, null);
            elements[2] = new MockElem(2, Math.Log(0.3), 0.4, elements[0]);
            {
                var vector = new HashSet <MockElem>()
                {
                    elements[1], elements[2]
                };
                state.Update(vector, new MockSample(1));
            }
            elements[3] = new MockElem(3, Math.Log(0.5), 0.6, null);
            {
                var vector = new HashSet <MockElem> {
                    elements[3]
                };
                state.Update(vector, new MockSample(2));
            }
            var seq = state.Sequence();

            Assert.Equal(0, seq.ElementAt(0).Id);
            Assert.Equal(1, seq.ElementAt(1).Id);
            Assert.Equal(3, seq.ElementAt(2).Id);
        }
Esempio n. 21
0
        void U_MysticalTomes()
        {
            if (MWorld.localTome.IsBlank() || MWorld.localManager == null)
            {
                return;
            }

            MWorld.localTome.Effects(player);

            if (--skillCD <= 0)
            {
                skillCD = 0;
            }

            if (KState.Down(AvalonMod.TomeSkillHotkey) && skillCD <= 0)
            {
                MWorld.localManager.Activate(player);

                NetHelper.SendModData(modBase, NetMessages.ActivateSkill, Main.myPlayer);

                skillCD = MWorld.localManager.Cooldown;
            }
        }
Esempio n. 22
0
    ///<summary>神をスポーンさせます。もういる(退出中等を含む)またはお椀が残っている場合はfalseを返す。</summary>
    public bool TryToPutKami(GameObject kami)
    {
        //神が出現してない、かつぜんざいのお椀が残ってないときだけ出る
        if (KamiState == KState.NoKami && ZenzaiState == ZState.NoZenzai)
        {
            KamiState  = KState.Coming;
            this._Kami = Instantiate(kami);
            //机の位置によってどっちからくるか決める
            if (transform.position.x > 0)
            {
                this._Kami.transform.position = new Vector3(7, transform.position.y + 0.7f, 2);
            }
            else
            {
                this._Kami.transform.position = new Vector3(-7, transform.position.y + 0.7f, 2);
            }

            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 23
0
 // Update is called once per frame
 void Update()
 {
     switch (meState) {
     case KState.WaitingForInput:
         if(UpdateWaitingForInput() )
             E_BoxClicked();
         break;
     case KState.Processing:
         if(! UpdateProcessing())
             E_BoxReleased();
         if(IsAllBeaconReady()){
             meState = KState.Locked;
             E_StateLocked();
         }
         break;
     case KState.Locked:
         break;
     }
     //if clicked see if any one of the boxs I have are clicked.
     //if mouse down then put the state to dragging
     //check if the dragged box is closer the the point I am planning to have it.
     //if it is close enough then release the box then set it to that position.
 }
Esempio n. 24
0
 public void SetFree()
 {
     meState = KState.FREE;
     Move (transform.position, posInit, .5f);
 }
Esempio n. 25
0
 public void SetLock(PatternBeacon beacon)
 {
     meState = KState.LOCKED;
     beaconLockedAt = beacon;
     Move (this.transform.position, beacon.transform.position, .5f);
 }
Esempio n. 26
0
 public void SetFree()
 {
     meState = KState.FREE;
     Move(transform.position, posInit, .5f);
 }
Esempio n. 27
0
 bool UpdateProcessing()
 {
     if (Input.GetAxis ("Mouse X") != 0 || Input.GetAxis ("Mouse Y") != 0) {
         var pos0 = Camera.main.ScreenToWorldPoint (new Vector3(Input.mousePosition.x,Input.mousePosition.y,0) );
         var pos1 = Camera.main.ScreenToWorldPoint (new Vector3(Input.mousePosition.x,Input.mousePosition.y,1) );
         var pos = Camera.main.ScreenToWorldPoint (new Vector3(Input.mousePosition.x ,Input.mousePosition.y,POSITION_Z/ (pos1.z-pos0.z)) );
         boxSelected.Move (boxSelected.transform.position,
                           new Vector3(Mathf.Clamp(pos.x,-10,10),Mathf.Clamp(pos.y,-1,10), pos.z), .1f);
         //boxSelected.Move (boxSelected.transform.position, new Vector3(pos.x,pom.y, boxSelected.transform.position.z), .3f);
     }
     if (Input.GetMouseButtonUp (0)) {
         meState = KState.WaitingForInput;
         int n = GetTouchedBeacon(boxSelected);
         BoxTouchedBeacon(boxSelected,(n== -1)? null: beacons[n] );
         return false;
     }
     return true;
 }
Esempio n. 28
0
        public void TestKStateUnbound()
        {
            var elements = new Dictionary <int, MockElem>();

            elements.Add(0, new MockElem(0, Math.Log10(0.3), 0.3, null));
            elements.Add(1, new MockElem(1, Math.Log10(0.2), 0.2, null));
            elements.Add(2, new MockElem(2, Math.Log10(0.5), 0.5, null));

            var state = new KState <MockElem, MockStateTransition, MockSample>();

            {
                var vector = new HashSet <MockElem>(new MockElem[] { elements[0], elements[1], elements[2] });

                state.Update(vector, new MockSample(0));

                Assert.Equal(3, state.Count);
                Assert.Equal(2, state.Estimate().Id);
            }

            elements.Add(3, new MockElem(3, Math.Log10(0.3), 0.3, elements[1]));
            elements.Add(4, new MockElem(4, Math.Log10(0.2), 0.2, elements[1]));
            elements.Add(5, new MockElem(5, Math.Log10(0.4), 0.4, elements[2]));
            elements.Add(6, new MockElem(6, Math.Log10(0.1), 0.1, elements[2]));

            {
                var vector = new HashSet <MockElem>(new MockElem[] {
                    elements[3], elements[4], elements[5], elements[6]
                });

                state.Update(vector, new MockSample(1));

                Assert.Equal(6, state.Count);
                Assert.Equal(5, state.Estimate().Id);

                var sequence = new int[] { 2, 5 };
                for (int i = 0; i < state.Sequence().Count() - 1; ++i)
                {
                    Assert.Equal(sequence[i], state.Sequence().ElementAt(i).Id);
                }
            }

            elements.Add(7, new MockElem(7, Math.Log10(0.3), 0.3, elements[5]));
            elements.Add(8, new MockElem(8, Math.Log10(0.2), 0.2, elements[5]));
            elements.Add(9, new MockElem(9, Math.Log10(0.4), 0.4, elements[6]));
            elements.Add(10, new MockElem(10, Math.Log10(0.1), 0.1, elements[6]));

            {
                var vector = new HashSet <MockElem>(new MockElem[] {
                    elements[7], elements[8], elements[9], elements[10]
                });

                state.Update(vector, new MockSample(2));

                Assert.Equal(7, state.Count);
                Assert.Equal(9, state.Estimate().Id);

                var sequence = new int[] { 2, 6, 9 };
                for (int i = 0; i < state.Sequence().Count() - 1; ++i)
                {
                    Assert.Equal(sequence[i], state.Sequence().ElementAt(i).Id);
                }
            }

            elements.Add(11, new MockElem(11, Math.Log10(0.3), 0.3, null));
            elements.Add(12, new MockElem(12, Math.Log10(0.2), 0.2, null));
            elements.Add(13, new MockElem(13, Math.Log10(0.4), 0.4, null));
            elements.Add(14, new MockElem(14, Math.Log10(0.1), 0.1, null));

            {
                var vector = new HashSet <MockElem>(new MockElem[] {
                    elements[11],
                    elements[12],
                    elements[13],
                    elements[14]
                });

                state.Update(vector, new MockSample(3));

                Assert.Equal(8, state.Count);
                Assert.Equal(13, state.Estimate().Id);

                var sequence = new int[] { 2, 6, 9, 13 };
                for (int i = 0; i < state.Sequence().Count() - 1; ++i)
                {
                    Assert.Equal(sequence[i], state.Sequence().ElementAt(i).Id);
                }
            }
            {
                var vector = new HashSet <MockElem>();

                state.Update(vector, new MockSample(4));

                Assert.Equal(8, state.Count);
                Assert.Equal(13, state.Estimate().Id);

                var sequence = new int[] { 2, 6, 9, 13 };
                for (int i = 0; i < state.Sequence().Count() - 1; ++i)
                {
                    Assert.Equal(sequence[i], state.Sequence().ElementAt(i).Id);
                }
            }
        }
Esempio n. 29
0
 public void SetLock(PatternBeacon beacon)
 {
     meState        = KState.LOCKED;
     beaconLockedAt = beacon;
     Move(this.transform.position, beacon.transform.position, .5f);
 }
Esempio n. 30
0
 bool UpdateWaitingForInput()
 {
     if(!Input.GetMouseButtonDown(0) ) return false;
     boxSelected = GetCollidedBox();
     //boxSelectedPositionInit = boxSelected.transform.position;
     if(boxSelected == null) return false;
     meState = KState.Processing;
     return true;
 }
Esempio n. 31
0
    // Update is called once per frame
    void Update()
    {
        if (health <= 0)
        {
            health = -1;
            state  = KState.Dead;
        }
        if (transform.position.x < player.position.x)
        {
            if (facing)
            {
                transform.Rotate(new Vector3(0, 180));
                facing = false;
            }
        }
        else
        {
            if (!facing)
            {
                transform.Rotate(new Vector3(0, 180));
                facing = true;
            }
        }
        if (transform.position.y > player.position.y)
        {
            layering.sortingOrder = 1;
        }
        else
        {
            layering.sortingOrder = 2;
        }
        switch (state)
        {
        case KState.Idle:

            endTime -= Time.deltaTime;
            if (endTime < 0 && battleStart)
            {
                endTime = health / 10;
                state   = KState.Moving;
            }
            break;

        case KState.Moving:
            visuals.SetBool("Moving", true);
            if (Vector2.Distance(transform.position, player.position) > range)
            {
                transform.position = Vector2.MoveTowards(transform.position, player.position, (speed - (health / 10)) * Time.deltaTime);
            }
            if (Vector2.Distance(transform.position, player.position) <= range)
            {
                visuals.SetBool("Moving", false);
                state = KState.Attacking;
            }
            break;

        case KState.Attacking:
            if (!visuals.GetBool("Attacking"))
            {
                attackState++;
                if (attackState > 3)
                {
                    attackState = 1;
                }
                visuals.SetInteger("Attack", attackState);
                visuals.SetBool("Attacking", true);
            }
            break;

        case KState.Dead:
            if (!visuals.GetBool("Dead"))
            {
                visuals.SetBool("Dying", true);
            }

            break;

        case KState.Hit:
            if (cooldown)
            {
                health--;
                cooldown = false;
                visuals.SetBool("Hit", true);
            }

            break;
        }
    }
Esempio n. 32
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < 3; i++)
        {
            if (fukidashis[i].activeSelf && fukidashis[i].transform.localPosition.y < (-(System.Math.Abs(i - 1)) + 5) * 0.4f)
            {
                fukidashis[i].transform.position += new Vector3(0, 0.02f, 0);
                fukidashis[i].GetComponent <SpriteRenderer>().color += new Color(0, 0, 0, 0.03f);
            }
        }

        switch (KamiState)
        {
        //神が来るまで何もしない
        case KState.NoKami:
            //pass
            break;

        //出現~着席までの処理
        case KState.Coming:

            //右側の机の場合右から左に移動
            if (transform.position.x > 0)
            {
                Kami.transform.position += new Vector3(-0.05f, 0, 0);
                //机の前に来たら座る
                if (transform.position.x > Kami.transform.position.x)
                {
                    Kami.transform.position = new Vector3(transform.position.x, transform.position.y + 0.7f, 2);
                    KamiState         = KState.LackingOfZenzai;
                    FramesUntilGetOut = framesToGetOut;

                    fukidashis[0].SetActive(true);
                }
            }
            //左側の机の場合左から右に移動
            else
            {
                Kami.transform.position += new Vector3(0.05f, 0, 0);
                //机の前に来たら座る
                if (transform.position.x < Kami.transform.position.x)
                {
                    Kami.transform.position = new Vector3(transform.position.x, transform.position.y + 0.7f, 2);
                    KamiState         = KState.LackingOfZenzai;
                    FramesUntilGetOut = framesToGetOut;

                    fukidashis[0].SetActive(true);
                }
            }

            break;

        //着席かつぜんざいがない->どんどん耐えられなくなる(スコアは増える)
        case KState.LackingOfZenzai:
            ScoreHolder.Instance.score += 1;

            FramesUntilGetOut--;
            if (FramesUntilGetOut == 0)
            {
                KamiState = KState.Leaving;

                for (int k = 0; k < 3; k++)
                {
                    fukidashis[k].transform.position = new Vector3((k - 1) * 0.7f, (-(System.Math.Abs(k - 1)) + 3) * 0.4f, -2)
                                                       + transform.position;
                    fukidashis[k].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0);
                    fukidashis[k].SetActive(false);
                }
            }
            else if (FramesUntilGetOut == 100)
            {
                fukidashis[1].SetActive(true);
                fukidashis[2].SetActive(true);
            }

            break;

        //食べてる(一定時間で完食)
        case KState.Eating:
            ScoreHolder.Instance.score++;
            FramesUntilAteUp--;
            if (FramesUntilAteUp == 0)
            {
                //完食処理
                KamiState         = KState.Ate;
                ZenzaiState       = ZState.WasEaten;
                FramesUntilGetOut = framesToGetOut;
                zenzaiObj.GetComponent <SpriteRenderer>().sprite = zenzaiAteSpr;

                fukidashis[0].SetActive(true);
            }
            break;

        //完食後(LackingOfZenzaiと同じ処理)
        case KState.Ate:
            ScoreHolder.Instance.score += 1;

            FramesUntilGetOut--;
            if (FramesUntilGetOut == 0)
            {
                KamiState = KState.Leaving;

                for (int k = 0; k < 3; k++)
                {
                    fukidashis[k].transform.position = new Vector3((k - 1) * 0.7f, (-(System.Math.Abs(k - 1)) + 3) * 0.4f, -2)
                                                       + transform.position;
                    fukidashis[k].GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0);
                    fukidashis[k].SetActive(false);
                }
            }
            else if (FramesUntilGetOut == 100)
            {
                fukidashis[1].SetActive(true);
                fukidashis[2].SetActive(true);
            }

            break;

        //退出、画面外に出たら消す
        case KState.Leaving:

            //右側の机の場合左から右に移動
            if (transform.position.x > 0)
            {
                Kami.transform.position -= new Vector3(-0.05f, 0, 0);
                //画面外に来たら消す
                if (Kami.transform.position.x > 8)
                {
                    Destroy(Kami);
                    _Kami     = null;
                    KamiState = KState.NoKami;
                }
            }
            //左側の机の場合右から左に移動
            else
            {
                Kami.transform.position -= new Vector3(0.05f, 0, 0);
                //画面外に来たら消す
                if (Kami.transform.position.x < -8)
                {
                    Destroy(Kami);
                    _Kami     = null;
                    KamiState = KState.NoKami;
                }
            }

            break;
        }
    }