示例#1
0
    private void Update()
    {
        if (Play != MoveMode.Forward)
        {
            Anim.ChangeFps(0);
            return;
        }
        else
        {
            Anim.ChangeFps(12);
        }

        var dt = Time.deltaTime;

        var hray = Physics2D.Raycast(transform.position + Vector3.up * 0.2f, Velocity.normalized, 0.5f, 1 << 8);

        if (hray)
        {
            Jump();
        }

        if (Velocity.x == 0)
        {
            IsLeft = !IsLeft;
            SetVelocity(Vector2.zero);
        }

        AddVelocity((IsLeft ? Vector2.left : Vector2.right) * (hspeed * dt));
    }
示例#2
0
    private void Update()
    {
        if (Play != MoveMode.Forward)
        {
            Anim.ChangeFps(0);
            return;
        }
        else
        {
            Anim.ChangeFps(12);
        }

        _timer += Time.deltaTime;

        if (IsShooter)
        {
            ShooterUpdate();
        }
        if (IsFollower)
        {
            FollowerUpdate();
        }

        if (IsHitter)
        {
            HitUpdate();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Play != MoveMode.Forward)
        {
            Anim.ChangeFps(0);
            return;
        }
        else
        {
            Anim.ChangeFps(12);
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            GetHit(new DamageInfo());
        }

        var hInput = Input.GetAxis("Horizontal");

        if (hInput != 0)
        {
            if (OnFloor)
            {
                Anim.SetAnim("Walk");
            }
            AddVelocity(Vector2.right * (hInput * Time.deltaTime));
        }
        else
        {
            if (OnFloor)
            {
                Anim.SetAnim("Stand");
            }
        }
        if (OnFloor && Input.GetKeyDown(KeyCode.Space))
        {
            Anim.SetAnim("JumpStart");
            OnFloor = false;
            AddVelocity(Vector2.up * jumpPower);
        }

        if (Velocity.y < 0)
        {
            Anim.SetAnim("FallStart");
        }
    }
示例#4
0
    private void FollowerUpdate()
    {
        Anim.SetAnim("walk");
        Anim.ChangeFps(12);

        var pos = transform.position;

        var hray = Physics2D.Raycast(pos + Vector3.up * 0.5f, Velocity.normalized, 2f, 1 << 8);

        if (hray)
        {
            Jump();
        }

        var dt = Time.deltaTime;

        IsLeft = LittleGirl.self.Position.x < transform.position.x;

        AddVelocity((IsLeft ? Vector2.left : Vector2.right) * (hspeed * dt));
    }
示例#5
0
    private void FollowerUpdate()
    {
        if (Play != MoveMode.Forward)
        {
            Anim.ChangeFps(0);
            return;
        }
        else
        {
            Anim.ChangeFps(12);
        }

        var ray = Physics2D.BoxCastAll(transform.position, ((BoxCollider2D)Collider2D).size + Vector2.one,
                                       0, Vector2.zero, 0);

        if (ray.Length > 0)
        {
            foreach (var hit in ray)
            {
                var iHit = hit.transform.GetComponent <IHit>();
                if (iHit != null && hit.transform.gameObject.layer == 16)
                {
                    var dmgInfo = new DamageInfo();
                    dmgInfo.Damage = MeleeDamage;
                    dmgInfo.Getter = iHit;
                    dmgInfo.Giver  = this;

                    GiveHit(dmgInfo);
                }
            }
        }

        var dt = Time.deltaTime;

        IsLeft = LittleGirl.self.Position.x < transform.position.x;

        AddVelocity((IsLeft ? Vector2.left : Vector2.right) * (hspeed * dt));
    }