Ejemplo n.º 1
0
Archivo: Enemy.cs Proyecto: elleyer/tdg
 public void Update()
 {
     if (Health <= 0)
     {
         Destroyed?.Invoke(this);
     }
 }
Ejemplo n.º 2
0
        void OnVisualsChanged(object sender, VisualChangeEventArgs e)
        {
            if (_animateStatus)
            {
                StatusText.Text = string.Format(CultureInfo.InvariantCulture, "{0} live visuals of {1} total", grid.LiveVisualCount, _totalVisuals);

                int tick = Environment.TickCount;
                if (e.Added != 0 || e.Removed != 0)
                {
                    addedPerSecond   += e.Added;
                    removedPerSecond += e.Removed;
                    if (tick > lastTick + 100)
                    {
                        Created.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation(
                                                   Math.Min(addedPerSecond, 450),
                                                   new Duration(TimeSpan.FromMilliseconds(100))));
                        CreatedLabel.Text = addedPerSecond.ToString(CultureInfo.InvariantCulture) + " created";
                        addedPerSecond    = 0;

                        Destroyed.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation(
                                                     Math.Min(removedPerSecond, 450),
                                                     new Duration(TimeSpan.FromMilliseconds(100))));
                        DestroyedLabel.Text = removedPerSecond.ToString(CultureInfo.InvariantCulture) + " disposed";
                        removedPerSecond    = 0;
                    }
                }
                if (tick > lastTick + 1000)
                {
                    lastTick = tick;
                }
            }
        }
Ejemplo n.º 3
0
        public API(string ip, FadeProxyClient proxy, Mode mode = Mode.BOT)
        {
            _ip = ip;

            this.mode = mode;

            // Depedency injection
            Account        = new Account(this);
            _proxy         = proxy;
            _remoteClient  = new RemoteClient(this);
            _vanillaClient = new VanillaClient(this, proxy, _remoteClient);

            Account.LoginSucceed += (s, e) => Connect();

            _vanillaClient.AuthFailed   += (s, e) => AuthFailed?.Invoke(s, e);
            _vanillaClient.Disconnected += (s, e) => Disconnected?.Invoke(s, e);
            _vanillaClient.HeroInited   += (s, e) =>
            {
                HeroInited?.Invoke(s, e);
                if (LoginTime == DateTime.MinValue)
                {
                    LoginTime = DateTime.Now;
                }
            };
            _vanillaClient.Attacked   += (s, e) => Attacked?.Invoke(s, e);
            _vanillaClient.ShipMoving += (s, e) => ShipMoving?.Invoke(s, e);
            _vanillaClient.Destroyed  += (s, e) => Destroyed?.Invoke(s, e);
        }
Ejemplo n.º 4
0
 public override void Destroy()
 {
     explosionSprite.Hide();
     current = State.Dead;
     Destroyed?.Invoke(this, null);
     removeQueue.Enqueue(new Tuple <int, GameObject>(Id, this));
 }
Ejemplo n.º 5
0
 public void StartWork()
 {
     _isWorking = true;
     while (_isWorking)
     {
         if (_rnd.NextDouble() <= _crashProbability && !IsBroken)
         {
             IsBroken = true;
             Broken?.Invoke(this);
             _hpTimer          = new Timer(TimeSpan.FromSeconds(HP).TotalMilliseconds);
             _hpTimer.Elapsed += (o, e) =>
             {
                 Destroyed?.Invoke(this);
                 StopWork();
                 _hpTimer?.Stop();
             };
             _hpTimer.Start();
             return;
         }
         if (!IsBroken && Store.CurrentVolume < Store.Capacity)
         {
             Store.AddIron(1);
         }
         Thread.Sleep(1000);
     }
 }
    private IEnumerator DoSink()
    {
        Vector3 pos     = transform.localPosition;
        Vector3 sinkPos = pos - new Vector3(0, m_config.SinkHeight, 0);

        // Randomize sail falling left/right
        Quaternion startRot     = transform.rotation;
        Vector3    randRotation = startRot.eulerAngles + new Vector3(0, 0, Helpers.RandBool() ? -50.0f : 50.0f);
        Quaternion targRot      = Quaternion.Euler(randRotation);

        float time = 0.0f;

        while (time < m_config.DropTime)
        {
            time += Time.deltaTime;
            float t = Mathf.Clamp01(time / m_config.DropTime);
            transform.rotation = Quaternion.Slerp(startRot, targRot, t);

            t = m_config.SinkCurve.Evaluate(t);
            transform.localPosition = Vector3.LerpUnclamped(pos, sinkPos, t);
            yield return(null);
        }

        Destroyed?.Invoke(this);
        Destroy(gameObject);
    }
Ejemplo n.º 7
0
        private void Update()
        {
            if (_navigator.AppState == AppStates.Gameplay)
            {
                Points -= _appSettings.PointLossSpeed * Time.deltaTime;
                if (Points <= 0f)
                {
                    Destroyed.SafelyInvoke(this);
                }
            }

            if (Application.isEditor)
            {
                if (Input.GetKeyDown(KeyCode.Minus))
                {
                    Points -= 25f;
                    Debug.Log("Removing points");
                }
                if (Input.GetKeyDown(KeyCode.Equals))
                {
                    Points += 25f;
                    Debug.Log("Adding points");
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Called when graphics device has been detected to be internally destroyed.
        /// </summary>
        protected internal virtual void OnDestroyed()
        {
            Destroyed?.Invoke(this, EventArgs.Empty);

            ReleaseComObject(ref nativeDeviceChild);
            NativeResource = null;
        }
Ejemplo n.º 9
0
        public void Ride()
        {
            Destroyed += delegate
            {
                Console.WriteLine("The Bike is broken, repair it first");
                Console.ReadKey();
            };


            if (IsBroken)
            {
                Destroyed?.Invoke();
                return;
            }

            Random rand = new Random();

            Console.WriteLine("Riding for 1 hour...");
            Thread.Sleep(1000);
            Distance += Speed;


            int chance = rand.Next(1, 4);

            IsBroken = chance == 2 ? true : false;
            if (IsBroken)
            {
                Console.Clear();
                Destroyed?.Invoke();
            }
        }
Ejemplo n.º 10
0
        public void Destroy()
        {
            if (IsDestroyed)
            {
                return;
            }

            IsDestroyed = true;

            // Remove players
            foreach (var member in Members.Values.ToList())
            {
                RemovePlayer(member.Extension);
            }

            if (GameSpawnTask != null)
            {
                GameSpawnTask.StatusChanged -= OnSpawnServerStatusChanged;
                GameSpawnTask.KillSpawnedProcess();
            }

            if (Destroyed != null)
            {
                Destroyed.Invoke(this);
            }
        }
Ejemplo n.º 11
0
 public virtual void TakeDamage(float damage)
 {
     if (!isAlive || damage <= 0.0f)
     {
         return;
     }
     if (SupportRange.InSupportRange(gameObject))
     {
         damage *= 0.75f;
     }
     HeroUIScript.Damage(damage * (1.0f - dmgDamp * 0.01f), transform.position + Vector3.up *
                         10.0f);
     currHP -= damage * (1.0f - dmgDamp * 0.01f);
     Attacked?.Invoke();
     if (currHP <= 0.0f)
     {
         currHP  = 0.0f;
         isAlive = false;
         if (!(this is PortalInfo))
         {
             gameObject.SetActive(false);
             if (destroyable)
             {
                 Destroy(gameObject, 1.0f);
             }
         }
         Destroyed?.Invoke();
     }
 }
Ejemplo n.º 12
0
    public void Destroy()
    {
        Vector3 dropPosition = this.transform.position;

        Debug.Log("Bang!");
        Destroyed?.Invoke();

        /*float minAngle = Mathf.Atan2(-6f - dropPosition.x, dropPosition.y) * 6 * Mathf.PI;
         * float maxAngle = Mathf.Atan2(6f - dropPosition.x, dropPosition.y) * 6 * Mathf.PI;
         *
         * int rocketsInBB = UnityEngine.Random.Range(2, 4);
         * do
         * {
         *  float finalAngle = UnityEngine.Random.Range(minAngle, maxAngle);
         *  Debug.LogError($"Angle: {finalAngle}");
         *
         *  Quaternion spawnRotation = this.transform.rotation * Quaternion.Euler(0, finalAngle, 0);
         *  Instantiate(enemyRocket, dropPosition, spawnRotation);
         *  rocketsInBB--;
         *
         * } while (rocketsInBB != 0);*/

        float finalAngle = -20;

        for (int i = 0; i < rocketsInBB; i++)
        {
            Quaternion spawnRotation = this.transform.rotation * Quaternion.Euler(0, finalAngle, 0);
            Instantiate(enemyRocket, dropPosition, spawnRotation);
            finalAngle += 20;
        }

        Destroy(gameObject);
    }
Ejemplo n.º 13
0
    public void ApplyDamage(int dmg, Attack.DamageTypes damageType)
    {
        this.hitsTaken++;

        int damageAfterModifiers = dmg;

        for (int i = 0; i < this.modifiers.Count; i++)
        {
            damageAfterModifiers = this.modifiers[i].Apply(damageAfterModifiers, damageType);
        }

        this.HP = Mathf.Max(this.HP - damageAfterModifiers, 0);

        // Fire events
        if (this.HP <= 0)
        {
            if (Destroyed != null)
            {
                Destroyed.Invoke(this);
            }
        }
        else
        {
            if (TookDamage != null)
            {
                TookDamage.Invoke(this, damageAfterModifiers, this.HP);
            }
        }
    }
Ejemplo n.º 14
0
        public void Damage(float damage)
        {
            if (IsDestroyed)
            {
                return;
            }

            health = Mathf.Max(0, health - damage);
            if (IsDestroyed)
            {
                bodyRenderer.gameObject.SetActive(false);
                Transform modelTransform = bodyRenderer.transform;
                brokenTable = Instantiate(brokenTablePrefab, modelTransform.position, modelTransform.rotation, transform);

                Destroyed?.Invoke();

                if (IsTablesDestroyed())
                {
                    OnTablesDestroyed?.Invoke();
                }
            }
            else
            {
                float healthFraction = health / maxHealth;                 // should never be zero here
                int   damageIndex    = Mathf.FloorToInt((1f - healthFraction) * damageStates.Length);
                bodyRenderer.sharedMaterial = damageStates[damageIndex];
            }
        }
Ejemplo n.º 15
0
        public void Destroy()
        {
            if (IsDestroyed)
            {
                return;
            }

            IsDestroyed = true;

            Parent?.RemoveChild(this);

            foreach (var component in _components.ToArray())
            {
                component.Destroy();
            }

            foreach (var child in _children.ToArray())
            {
                child.Destroy();
            }

            Destroyed?.Invoke(this);

            Interlocked.Decrement(ref Scene.NumberNodes);
        }
Ejemplo n.º 16
0
 public void Destroy()
 {
     //Debug.Log("Bang!");
     Destroyed?.Invoke();
     //trailRenderer.transform.parent = null;
     //Destroy(trailRenderer.gameObject, 13);
     Destroy(gameObject);
 }
Ejemplo n.º 17
0
        public void Dispose()
        {
            m_App.Documents.DocumentActivated -= OnDocumentActivated;
            m_Model.StorageReadAvailable      -= OnStorageReadAvailable;
            m_Model.StorageWriteAvailable     -= OnStorageWriteAvailable;

            Destroyed?.Invoke(this);
        }
Ejemplo n.º 18
0
        public void Destroy()
        {
            IsDestroyed = true;

            Velocity = Vector2.Zero;

            Destroyed?.Invoke();
        }
Ejemplo n.º 19
0
        public void Destroy()
        {
            var oldContent = Content;

            Content = oldContent.Loot.GetInstance(this);
            oldContent.Hide();
            Destroyed?.Invoke(this);
        }
Ejemplo n.º 20
0
        public void Handle(Destroyed e)
        {
            var index = _elastic.Get <Responses.Index>(e.AccountId);

            _elastic.Delete <Responses.Index>(e.AccountId);

            _manager.Publish(index.Source, ChangeType.DELETE);
        }
Ejemplo n.º 21
0
 void OnDestroy()
 {
     if (!closing)
     {
         Destroyed.Raise(this, new GameObjectArgs(gameObject));
         Destroyed = null;
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        ///    Removes this SpaceObject from the world.
        /// </summary>
        public void Destroy()
        {
            Destroyed?.Invoke(this);

            WorldContext.SpaceObjects.Remove(this);
            Location.RemoveSpaceObject(this);
            WorldContext = null;
        }
Ejemplo n.º 23
0
 private void ChangeEnergy(int delta)
 {
     Energy += delta;
     if (Energy <= 0)
     {
         Destroyed?.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 24
0
    public void SetShowPredictiobCondition()
    {
        if (Convert.ToBoolean(PlayerPrefs.GetInt("IsTriesEnded")) == false)
        {
            string predictionText = _dataSaver.Predictions.ElementAt(UnityEngine.Random.Range(0, _dataSaver.Predictions.Count()));

            Destroyed?.Invoke(predictionText);
        }
    }
Ejemplo n.º 25
0
        public void ChangeEnergy(int delta)
        {
            _Energy += delta;

            if (_Energy < 0)
            {
                Destroyed?.Invoke(this, EventArgs.Empty);
            }
        }
            void IVirtualDesktopNotification.VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback)
            {
                var args = new VirtualDesktopDestroyEventArgs(FromComObject(pDesktopDestroyed), FromComObject(pDesktopFallback));

                if (Destroyed != null)
                {
                    Destroyed.Invoke(this, args);
                }
            }
Ejemplo n.º 27
0
    private IEnumerator DestroyDelay(float delay)
    {
        _canDestroy = false;
        Destroyed?.Invoke();
        yield return(new WaitForSeconds(delay));

        _canDestroy = true;
        ReadyToDestroy?.Invoke();
    }
Ejemplo n.º 28
0
        public void ChangeEnergyShip(int delta)
        {
            _EnergyShip += delta;

            if (_EnergyShip < 0)
            {
                Destroyed.Invoke(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 29
0
 private void Destroy(bool ev)
 {
     visible = false;
     Protocol.DiePacket(id).Send(level, this as Player);
     level.bodies.Remove(this);
     if (ev)
     {
         Destroyed.Raise(level.server, this);
     }
 }
Ejemplo n.º 30
0
    public void Damage(float damage)
    {
        health -= damage;

        if (health <= 0)
        {
            Destroyed?.Invoke();
            Destroy(gameObject);
        }
    }