Exemplo n.º 1
0
        private void Awake()
        {
            _userInfo           = new UserInfo();
            _unitsManager       = new UnitsManager();
            _damageSystem       = new DamageSystem();
            _pickupsManager     = new PickupsManager(_unitsManager, _userInfo, _pickupPrefab);
            _projectilesManager = new ProjectilesManager(_damageSystem);
            _goldLabel.Init(_userInfo);

            _damageSystem.DamageTaken += (u) => _camera.Shake(0.5f);
        }
Exemplo n.º 2
0
        public void ResolveCollision(UnitController defender, Collision2D collision)
        {
            if (defender == Game.Instance.CurrentUnit || !defender.IsActive || defender.Character == null)
            {
                return;
            }

            var attacker = collision.transform.GetComponent <UnitController>();

            if (attacker == null || !attacker.IsActive)
            {
                return;
            }

            if (defender.PlayerId != attacker.PlayerId)
            {
                if (defender.PlayerId == Game.Instance.CurrentUnit.PlayerId)
                {
                    return;
                }

                FMODUnity.RuntimeManager.PlayOneShot("event:/Punch");
                attacker.HitsCount.AddValue(1);
                defender.CollisionReaction?.Stop();
                defender.CollisionReaction = new SyncScenario(new List <ISyncScenarioItem>
                {
                    new ActionScenarioItem(() =>
                    {
                        if (DamageSystem.ApplyPassiveDamage(attacker, defender))
                        {
                            defender.IsActive = false;
                        }
                    }),
                    new ActionScenarioItem(() =>
                    {
                        if (!defender.IsActive || defender.Character == null)
                        {
                            FMODUnity.RuntimeManager.PlayOneShot("event:/Death");
                            defender.Die();
                        }
                    }),
                    new ScaleTween(gameObject, Vector3.one, 1f, EaseType.Linear)
                    {
                        TimeManager = GameSettings.AnimaitonTimeManager
                    },
                }, (scenario, force) => { transform.localScale = Vector3.one; })
                {
                    TimeManager = GameSettings.AnimaitonTimeManager
                };
                defender.CollisionReaction.Play();
            }
            else
            {
                defender.CastPassiveAbility(
                    new CastContext
                {
                    Caster = defender,
                    Target = attacker
                });
            }
        }