//bool mustDash;

        void Start()
        {
            rigidBody = GetComponent <Rigidbody2D>();

            IsDashing.SetValue(false);
            DashElaspedTime.SetValue(DashRate.Value);

            WalkSpeed.SetValue(WalkSpeedStandard);
            DashRate.SetValue(DashRateStandard);

            sprite = GetComponentInChildren <SpriteRenderer>();

            foreach (Transform t in transform)
            {
                if (t.name == "Body")
                {
                    characterAnimator = t.GetComponent <Animator>();
                }
            }
        }
Beispiel #2
0
        void Update()
        {
            FireElaspedTime.ApplyChange(Time.deltaTime);

            if (PV == null)
            {
                PV = GetComponent <PhotonView>();
            }

            Vector2 direction    = Inputs.Actions.Gameplay.FireDirection.ReadValue <Vector2>();
            bool    hasTriggered = Inputs.Actions.Gameplay.Fire.ReadValue <float>() > 0.1f;

            if (hasTriggered || direction.magnitude > 0.1f)
            {
                // in case of click, we need to compute the direction using the mouse position
                if (direction.magnitude <= 0.1f)
                {
                    direction = (FollowCamera.GetWorldPoint() - new Vector2(transform.position.x, transform.position.y));
                }

                direction.Normalize();

                if (FireAllowed.Value && !IsDead.Value && FireElaspedTime.Value > FireRate.Value)
                {
                    FireElaspedTime.SetValue(0.0f);

                    // adding a bit of the direction vector to the position so the bullet does spawn at the character center
                    Vector3 position = transform.position + new Vector3(direction.x, direction.y, transform.position.z) * 0.9f;

                    proxy.Fire(PhotonNetwork.LocalPlayer.ActorNumber, position, direction);
                    weaponAnimator.SetTrigger("Fire");
                }
            }

            Vector3 cameraWorldPosition = new Vector3(FollowCamera.GetWorldPoint().x, FollowCamera.GetWorldPoint().y, weaponAnimator.transform.position.z);

            if (cameraWorldPosition.x < weaponAnimator.transform.position.x)
            {
                weaponAnimator.GetComponent <SpriteRenderer>().flipX = true;
                weaponAnimator.transform.position = gunPos2.position;
                weaponAnimator.transform.right    = weaponAnimator.transform.position - cameraWorldPosition;
            }
            else
            {
                weaponAnimator.GetComponent <SpriteRenderer>().flipX = false;
                weaponAnimator.transform.position = gunPos1.position;
                weaponAnimator.transform.right    = cameraWorldPosition - weaponAnimator.transform.position;
            }
        }
Beispiel #3
0
        public void Add(Booster booster)
        {
            currentBoosters.RemoveAll(b =>
            {
                if (b.type == booster.type)
                {
                    OnRemove(b.type);
                    return(true);
                }

                return(false);
            });


            booster.durationLeft = booster.duration;

            switch (booster.type)
            {
            case Booster.Type.Shield:
                break;

            case Booster.Type.Speed:
                WalkSpeed.SetValue(booster.walkSpeedBooster);
                break;

            case Booster.Type.Invincible:
                proxy.EnableInvincibleColor(true);
                break;

            case Booster.Type.NoCooldownDash:
                DashRate.SetValue(DashRateBooster);
                break;
            }

            currentBoosters.Add(booster);
        }
 public void Equip(Weapon.Type newWeaponType)
 {
     PV.RPC(RPC_Functions.Equip, RpcTarget.All, newWeaponType);
     AmmoLeft = equiped.ammo;
     FireRate.SetValue(equiped.fireRate);
 }