Ejemplo n.º 1
0
 private List <DefensiveBattleController.CameraEventData> GetMostReleventCameraEvents()
 {
     if (this.cameraEvents.Count > 0)
     {
         DefensiveCameraEventType defensiveCameraEventType = DefensiveCameraEventType.None;
         if (this.currentCameraEvent != null)
         {
             defensiveCameraEventType = this.currentCameraEvent.type;
         }
         List <DefensiveBattleController.CameraEventData> list = new List <DefensiveBattleController.CameraEventData>();
         float num  = 10f;
         float time = Time.time;
         for (int i = this.cameraEvents.Count - 1; i >= 0; i--)
         {
             DefensiveBattleController.CameraEventData cameraEventData = this.cameraEvents[i];
             if (this.currentCameraEvent != null)
             {
                 Vector2 a = new Vector2(cameraEventData.posX, cameraEventData.posZ);
                 Vector2 b = new Vector2(this.currentCameraEvent.posX, this.currentCameraEvent.posZ);
                 num = Math.Abs(Vector2.Distance(a, b));
             }
             if (num >= 10f && time < cameraEventData.timeStamp + this.GetExpirationTimeForEvent(cameraEventData.type) && cameraEventData.type <= defensiveCameraEventType)
             {
                 list.Add(cameraEventData);
             }
         }
         return(list);
     }
     return(null);
 }
Ejemplo n.º 2
0
        private void MoveCameraToAction()
        {
            if (!this.autoMoveCamera)
            {
                return;
            }
            List <DefensiveBattleController.CameraEventData> mostReleventCameraEvents = this.GetMostReleventCameraEvents();

            if (mostReleventCameraEvents != null && mostReleventCameraEvents.Count > 0)
            {
                float num  = 0f;
                float num2 = 0f;
                foreach (DefensiveBattleController.CameraEventData current in mostReleventCameraEvents)
                {
                    num  += current.posX;
                    num2 += current.posZ;
                }
                Vector3 zero = Vector3.zero;
                zero.x = num / (float)mostReleventCameraEvents.Count;
                zero.z = num2 / (float)mostReleventCameraEvents.Count;
                Vector3 vector = Service.CameraManager.MainCamera.Camera.WorldToViewportPoint(zero);
                this.currentCameraEvent      = mostReleventCameraEvents[0];
                this.currentCameraEvent.posX = zero.x;
                this.currentCameraEvent.posZ = zero.z;
                if ((double)vector.x < 0.1 || (double)vector.x > 0.9 || (double)vector.y < 0.1 || (double)vector.y > 0.9)
                {
                    Service.WorldInitializer.View.PanToLocation(zero);
                }
            }
            else
            {
                this.currentCameraEvent = null;
            }
        }
Ejemplo n.º 3
0
 private void AddCameraEvent(float x, float z, DefensiveCameraEventType type)
 {
     if (!this.autoMoveCamera)
     {
         return;
     }
     DefensiveBattleController.CameraEventData cameraEventData = new DefensiveBattleController.CameraEventData();
     cameraEventData.posX      = x;
     cameraEventData.posZ      = z;
     cameraEventData.type      = type;
     cameraEventData.timeStamp = Time.time;
     this.cameraEvents.Add(cameraEventData);
     this.MoveCameraToAction();
 }
Ejemplo n.º 4
0
 public void EndEncounter()
 {
     if (!this.activeDefenseBattle)
     {
         return;
     }
     this.eventManager.UnregisterObserver(this, EventId.EntityKilled);
     if (this.currentMission.IsRaidDefense())
     {
         Service.RaidDefenseController.OnEndRaidDefenseMission(this.waves[this.currentWaveIndex].Encounter.Uid);
     }
     this.currentMission      = null;
     this.activeDefenseBattle = false;
     this.currentCameraEvent  = null;
     for (int i = 0; i < this.timers.Count; i++)
     {
         this.timerManager.KillSimTimer(this.timers[i]);
     }
     this.timers.Clear();
     this.cameraEvents.Clear();
     this.numTimesEntityHit.Clear();
     this.UnRegisterObservers();
     Service.CurrentPlayer.DamagedBuildings = Service.BattleController.GetBuildingDamageMap();
 }