Esempio n. 1
0
        public override void Start()
        {
            GenerateWorkPath();
            navStopEventHandler.AddListener(OnNavStop);
            ;

            farmerBackEventHandler += Drop;
            farmerBackEventHandler += sidePlayer.FarmerBack;

            //死亡处理
            UnitDeathEventHandler.AddListener((p, m) =>
            {
                sidePlayer.FarmerCount--;
                sidePlayer.RoadFarmers[(int)road]--;
                sidePlayer.RoadWorkingFarmers[(int)road]--;
            });


            if (ResouceCarried > 0)
            {
                InitTarget = _home;
            }
            else
            {
                ResouceCarried = 0;
                InitTarget     = _targerResource;
            }


            base.Start();
        }
Esempio n. 2
0
 protected virtual void Awake()
 {
     _enemyPlayer = sidePlayer == GameManager.GameManager.GetManager.aSide
         ? GameManager.GameManager.GetManager.bSide
         : GameManager.GameManager.GetManager.aSide;
     unitRigidbody      = GetComponent <Rigidbody>();
     _destinationSetter = GetComponent <AIDestinationSetter>();
     pathFinder         = GetComponent <RichAI>();
     UnitDeathEventHandler.AddListener((p, m) => { p.ChangeResource(GameResourceType.Gold, deathReward); });
 }
Esempio n. 3
0
        protected override void Awake()
        {
            _maxHp        = this.HP;
            unitRigidbody = GetComponent <Rigidbody>();
            UnitDeathEventHandler.AddListener((p, m) => { p.ChangeResource(GameResourceType.Gold, deathReward); });
            BeAttackedEventHandler.AddListener(mUnit =>
            {
                var momentum = mUnit.GetUnit().unitRigidbody.velocity.magnitude *
                               mUnit.GetUnit().unitRigidbody.mass;
                var damage = momentum - defence > 0 ? momentum - defence : 1;

                var mainModule          = attackedEffect.GetComponent <ParticleSystem>().main;
                mainModule.maxParticles = (int)Mathf.Lerp(0f, 1000f, damage / this._maxHp);
                var effect = Instantiate(attackedEffect, transform.position,
                                         Quaternion.Euler(0, 0, 0), transform.parent);
                Destroy(effect, 5f);
            });
            UnitDeathEventHandler.AddListener((player, mUnit) =>
            {
                Instantiate(deathEffect, transform.position,
                            Quaternion.Euler(0, 0, 0), transform.parent);
            });
        }