コード例 #1
0
    private void Reverse()
    {
        var nowDerection = -1 * _base.localScale.x;

        _base.localScale = new Vector3(nowDerection, _base.localScale.y, _base.localScale.z);
        CurrentDerection = (Derection)((int)CurrentDerection * -1);
    }
コード例 #2
0
 public void SetDerection(Derection newDerection)
 {
     if (newDerection != CurrentDerection)
     {
         Reverse();
     }
 }
コード例 #3
0
    private void Update()
    {
        if (!gl.mainHero.IsAlife)
        {
            SceneManager.LoadScene("Died");
        }
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            StartCoroutine(SpiritDash.SpiritPath(this));
            _rigidBody.velocity        = Vector3.zero;
            _rigidBody.angularVelocity = 0;
        }

        if (EnableMove)
        {
            float axis      = Input.GetAxis("Horizontal");
            float derection = Input.GetAxisRaw("Horizontal");

            if (derection != 0)
            {
                var nd = axis > 0 ? Derection.Right : Derection.Left;
                if (nowDerection != nd)
                {
                    scale.x     *= -1;
                    nowDerection = nd;
                }
                transform.localScale = scale;
            }


            _rigidBody.transform.position += new Vector3(axis, 0) * 0.05f;
#if MYDEBUG
            if (Input.GetKeyDown(KeyCode.J))
            {
                Jumper.Inc();
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                SpiritDash.Enabled = true;
            }

            if (Input.GetKeyDown(KeyCode.K))
            {
                Dasher.Enabled = true;
            }
#endif
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                Dasher.Dash(_rigidBody, nowDerection);
            }


            if (Input.GetKeyDown(KeyCode.Space))
            {
                StartCoroutine(Jumper.Jump(_rigidBody));
            }
        }
    }
コード例 #4
0
ファイル: Snake.cs プロジェクト: GARRO1994/Snake
 public Snake(Point tail, int length, Derection _derection)
 {
     derection = _derection;
     pointLis  = new List <Point>();
     for (int i = 0; i < length; i++)
     {
         Point p = new Point(tail);
         p.Move(i, derection);
         pointLis.Add(p);
     }
 }
コード例 #5
0
ファイル: Bound.cs プロジェクト: Inferno-EK/Dreamer_Dreams
    public void DestroyWay(Derection derection)
    {
        if (derection == Derection.Right)
        {
            Destroy(RightWay);
        }
        else
        {
            Destroy(LeftWay);
        }

        Destroy(gameObject);
    }
コード例 #6
0
ファイル: Snake.cs プロジェクト: GARRO1994/Snake
 public void HandleKey(ConsoleKey key)
 {
     if (key == ConsoleKey.LeftArrow)
     {
         derection = Derection.LEFT;
     }
     else if (key == ConsoleKey.RightArrow)
     {
         derection = Derection.RIGHT;
     }
     else if (key == ConsoleKey.DownArrow)
     {
         derection = Derection.DOWN;
     }
     else if (key == ConsoleKey.UpArrow)
     {
         derection = Derection.UP;
     }
 }
コード例 #7
0
ファイル: Point.cs プロジェクト: GARRO1994/Snake
 public void Move(int offset, Derection derection)
 {
     if (derection == Derection.RIGHT)
     {
         x = x + offset;
     }
     else if (derection == Derection.LEFT)
     {
         x = x - offset;
     }
     else if (derection == Derection.UP)
     {
         y = y - offset;
     }
     else if (derection == Derection.DOWN)
     {
         y = y + offset;
     }
 }
コード例 #8
0
    private void Awake()
    {
        GameObjectSliderToChangeSkin.GetComponent <GradientSlider>().onChangeColorEvent += (Color color) => { NextColor = color; };


        _base         = transform;
        _sprites      = new List <SpriteRenderer>();
        _extraSprites = new List <SpriteRenderer>();

        for (int i = 0; i < transform.childCount; ++i)
        {
            var child = transform.GetChild(i);

            if (child.GetComponent <SpriteRenderer>() != null)
            {
                if (child.GetComponent <Rigidbody2D>() != null)
                {
                    _sprites.Add(child.GetComponent <SpriteRenderer>());
                }
                else
                {
                    ExtraColor.Add(Color.white);
                    _extraSprites.Add(child.GetComponent <SpriteRenderer>());
                }
            }

            for (int j = 0; j < child.childCount; ++j)
            {
                var сhallenger = child.GetChild(j);

                if (сhallenger.GetComponent <SpriteRenderer>() != null)
                {
                    if (сhallenger.GetComponent <Rigidbody2D>() != null)
                    {
                        _sprites.Add(сhallenger.GetComponent <SpriteRenderer>());
                    }
                    else
                    {
                        switch (сhallenger.name)
                        {
                        case "heir":
                            __heirId = ExtraColor.Count;
                            _toHeirComplex.onChangeColorEvent += SetHeirColor;
                            _heirSellector.onValueChange      += (Sprite toChange, int number) => { _extraSprites[__heirId].sprite = toChange; };
                            break;

                        case "eyeBack":
                            __eyeBackId = ExtraColor.Count;
                            _toEyeComplex.onChangeColorEvent += SetEyeColor;
                            break;

                        case "eyeFront":
                            __eyeFrontId = ExtraColor.Count;
                            _eyeSellector.onValueChange += (Sprite toChange, int number) => { _extraSprites[__eyeFrontId].sprite = toChange; };
                            break;

                        case "mouse":
                            __mouseId = ExtraColor.Count;
                            _mouseSellector.onValueChange += (Sprite toChange, int number) => { _extraSprites[__mouseId].sprite = toChange; };
                            break;
                        }

                        ExtraColor.Add(Color.white);
                        _extraSprites.Add(сhallenger.GetComponent <SpriteRenderer>());
                    }
                }
            }
        }

        _delta    = 1f;
        _nowColor = Color.white;
        SetColor(Color.clear);
        SetExtraColor();

        CurrentDerection = Derection.Left;
    }