Example #1
0
        /// <summary>
        /// 触发删除该集合中的actor武器
        /// </summary>
        public void Destroy(IEnumerable <UserData> list)
        {
            for (int i = 0; i < list.Count(); i++)
            {
                var weaponBaseContainer = list.ElementAt(i);

                OnDestroy?.Invoke(weaponBaseContainer.ActorID);

                if (level.GetActor(weaponBaseContainer.ActorID) is ISkillComponentContainer weapon)
                {
                    weapon.DestroySkill();
                }
                //Log.Trace("Destory 火控组件销毁一个武器"+weaponBaseContainer.ActorID+" 类型"+weaponBaseContainer.ActorType);
                skillInitList.Remove(weaponBaseContainer);
            }
            //foreach (var weaponBaseContainer in list)
            //{
            //    //var actor = level.GetActor(weaponBaseContainer.ActorID) as ISkillContainer;
            //    skillInitList.Remove(weaponBaseContainer);
            //    OnDestroy?.Invoke(weaponBaseContainer.ActorID);
            //    level.AddEventMessagesToHandlerForward(new DestroyEventMessage(weaponBaseContainer.ActorID));

            //    //actor?.DestroySkill();
            //}
        }
Example #2
0
 public void Destroy()
 {
     if (OnDestroy != null)
     {
         OnDestroy.Invoke(this, new OnDestroyEventArgs(this));
     }
 }
Example #3
0
        public void Destroy()
        {
            lock (this)
            {
                if (!_isValid)
                {
                    return;
                }
                _isValid = false;
                try
                {
                    OnDestroy?.Invoke(this);
                }
                catch (Exception e)
                {
                    _logger?.WriteException(e);
                }
            }

            _timerManager.Destroy();
            _objectCache.Destroy();
            _typeDB.Destroy();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            ExecutePendingActions();

            // _rwlock.EnterWriteLock();
            for (int i = 0, count = _contextRefs.Count; i < count; i++)
            {
                var contextRef = _contextRefs[i];
                contextRef.target.Destroy();
            }

            _contextRefs.Clear();
            _mainContext = null;
            // _rwlock.ExitWriteLock();


            if (_asyncManager != null)
            {
                _asyncManager.Destroy();
                _asyncManager = null;
            }

            JSApi.JS_FreeRuntime(_rt);
            var id = _runtimeId;

            _runtimeId = -1;
            _rt        = JSRuntime.Null;

            try
            {
                OnAfterDestroy?.Invoke(id);
            }
            catch (Exception e)
            {
                _logger?.WriteException(e);
            }
        }
 /// <summary>
 /// IDestructible interface.
 /// </summary>
 public void Destroy()
 {
     destroyed = true;
     attached  = false;
     connection.SendDetachRequest(instanceId);
     OnDestroy?.Invoke(this);
 }
Example #5
0
        /// <summary>
        /// 触发删除该类型的所有Actor武器
        /// </summary>
        public void Destroy(int i)
        {
            List <UserData> weaponList = new List <UserData>();

            for (var j = 0; j < skillInitList.Count; j++)
            {
                if (skillInitList[j].ActorType == i)
                {
                    //判断该生成列表中的对象是否已经在世界中
                    if (level.ContainsID(skillInitList[j].ActorID))
                    {
                        weaponList.Add(skillInitList[j]);
                    }
                }
            }
            //从集合中删除
            foreach (var weaponBaseContainer in weaponList)
            {
                //var actor = level.GetActor(weaponBaseContainer.ActorID) as ISkillContainer;
                skillInitList.Remove(weaponBaseContainer);
                OnDestroy?.Invoke(weaponBaseContainer.ActorID);
                if (level.GetActor(weaponBaseContainer.ActorID) is ISkillComponentContainer weapon)
                {
                    weapon.DestroySkill();
                }
                //actor?.DestroySkill();
            }
        }
Example #6
0
        public void Destroy()
        {
            _isValid = false;

            try
            {
                OnDestroy?.Invoke(this);
            }
            catch (Exception e)
            {
                _runtime.GetLogger().Error(e);
            }
            _atoms.Clear();

            JSApi.JS_FreeValue(_ctx, _numberConstructor);
            JSApi.JS_FreeValue(_ctx, _stringConstructor);
            JSApi.JS_FreeValue(_ctx, _globalObject);
            JSApi.JS_FreeValue(_ctx, _operatorCreate);

            JSApi.JS_FreeValue(_ctx, _moduleCache);
            JSApi.JS_FreeValue(_ctx, _require);
            JSApi.JS_FreeContext(_ctx);

            if (_coroutines != null)
            {
                Object.DestroyImmediate(_coroutines);
                _coroutines = null;
            }

            _ctx = JSContext.Null;
        }
Example #7
0
    private IEnumerator DestroyMe()
    {
        yield return(new WaitForSeconds(destroyTime));

        OnDestroy?.Invoke();
        Destroy(gameObject);
    }
Example #8
0
 public void Destroy()
 {
     Close();
     Receiver             = null;
     receiveNetworkBuffer = null;
     OnDestroy?.Invoke(this);
     OnDestroy = null;
 }
Example #9
0
 public virtual void Destroy()
 {
     foreach (Component c in components)
     {
         c.Destroy();
     }
     OnDestroy?.Invoke(this);
 }
Example #10
0
        public void Destroy()
        {
            if (myState == ObjectState.OnFire)
            {
                myState = ObjectState.Chared;
            }

            OnDestroy?.Invoke(this, myState);
        }
Example #11
0
 public void Damage(float amount)
 {
     health = Mathf.Clamp(health - amount, 0, config.MaxHealth);
     OnHealthChanged?.Invoke(health, amount);
     if (health <= 0)
     {
         OnDestroy?.Invoke();
     }
 }
Example #12
0
 /// <summary>
 /// Signal to the client that the battle has ended along with whether the attackers or defenders won.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private async void OnEndOfBattle(object sender, EndOfBattleEventArgs args)
 {
     var tasks = new List <Task>
     {
         _battleHubContext.Clients.Users(args.ParticipantIds).SendAsync("endBattle", args.DidAttackersWin),
         Task.Run(() => OnDestroy?.Invoke(this, new EventArgs()))
     };
     await Task.WhenAll(tasks);
 }
Example #13
0
 public void DestroyFirefly()
 {
     GameManager.Instance.DestroyFireflyEvent += delegate {
         OnDestroy.Invoke();
         Destroy(gameObject);
         gm.fireflies.Remove(this);
         positions.Terminer();
     };
 }
Example #14
0
    public virtual void Destroy()
    {
        InteractionZone.Instance.targets.Remove(this);

        SetHighlighted(false);

        Destroy(gameObject);

        onDestroy?.Invoke(this);
    }
Example #15
0
        public virtual void Destoy()
        {
            if (Destroyed)
            {
                return;
            }

            OnDestroy?.Invoke(this);
            Destroyed = true;
        }
Example #16
0
    public void Destroy(Owner damageSourceOwner)
    {
        if (IsDestroyed)
        {
            return;
        }

        Instantiate(_explosion, transform.position, Quaternion.identity).GetComponent <Explosion>().SetOwner(damageSourceOwner);
        IsDestroyed = true;
        OnDestroy?.Invoke(damageSourceOwner);
    }
 private void Update()
 {
     if (!hasFocus)
     {
         if (Input.anyKeyDown)
         {
             OnDestroy?.Invoke();
             GameObject.Destroy(this);
         }
     }
 }
Example #18
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <PlayerController>())
     {
         if (InputInventory.Instance.AddToInventory(MyInput))
         {
             OnDestroy?.Invoke();
             Destroy(gameObject);
         }
     }
 }
Example #19
0
    private void DestroyBlock()

    {
        if (IsNeedToCreateBonus())
        {
            int randIndex = Random.Range(0, pickUpPrefabs.Length);
            Instantiate(pickUpPrefabs[randIndex], transform.position, Quaternion.identity);
        }

        Destroy(gameObject);
        OnDestroy?.Invoke(this);
    }
Example #20
0
 private void Hit() // проверка удара
 {
     currentHits++;
     if (currentHits == NumberHit) // если удар последний
     {
         OnDestroy?.Invoke(this);
         Destroy(gameObject);
     }
     else
     {
         UpdateView();
     }
 }
 private void OnDisable()
 {
     OnDestroy?.Invoke();
     foreach (var sequence in sequences)
     {
         sequence.ResetSequence();
         sequence.onStartSequence    -= StartSequence;
         sequence.onCompletedSection -= OnCorrectSequence;
         foreach (var section in sequence.commands)
         {
             section.onCorrectInput -= OnCorrectInput;
         }
     }
 }
Example #22
0
 public void Destroy()
 {
     Close();
     //OnClose = null;
     //OnConnect = null;
     //OnReceive = null;
     receiveNetworkBuffer = null;
     //sock.OnReceive -= Sock_OnReceive;
     //sock.OnClose -= Sock_OnClose;
     //sock.OnConnect -= Sock_OnConnect;
     sock.Receiver = null;
     sock          = null;
     OnDestroy?.Invoke(this);
     OnDestroy = null;
 }
Example #23
0
        public void Destroy()
        {
            if (!_isValid)
            {
                return;
            }
            _isValid = false;

            try
            {
                OnDestroy?.Invoke(this);
            }
            catch (Exception e)
            {
                _runtime.GetLogger()?.WriteException(e);
            }
            _stringCache.Destroy();
            _atoms.Clear();

            JSApi.JS_FreeValue(_ctx, _numberConstructor);
            JSApi.JS_FreeValue(_ctx, _stringConstructor);
            JSApi.JS_FreeValue(_ctx, _functionConstructor);
            JSApi.JS_FreeValue(_ctx, _globalObject);
            JSApi.JS_FreeValue(_ctx, _operatorCreate);

            JSApi.JS_FreeValue(_ctx, _moduleCache);
            JSApi.JS_FreeValue(_ctx, _require);
            JSApi.JS_FreeContext(_ctx);
            var id = _contextId;

            _contextId = -1;

            if (_coroutines != null)
            {
                _coroutines.Destroy();
                _coroutines = null;
            }

            _ctx = JSContext.Null;
            try
            {
                OnAfterDestroy?.Invoke(id);
            }
            catch (Exception e)
            {
                _runtime.GetLogger()?.WriteException(e);
            }
        }
Example #24
0
        /// <summary>
        /// Removes the player's entity from the map in preparation for a log out.
        /// </summary>
        public void EndConnection()
        {
            lock (_lock)
            {
                if (IsActive)
                {
                    LastAccessed = DateTime.Now;
                    _currentMapManager.RemoveEntity(Entity);
                    _currentMapManager.GameTick       -= OnGameTick;
                    _mapBattleManager.OnCreatedBattle -= OnCreatedBattle;
                    IsActive = false;
                }
            }

            OnDestroy?.Invoke(this, new System.EventArgs());
        }
Example #25
0
    // public INetworkReceiver<NetworkConnection> Receiver { get; set; }

    public virtual void Destroy()
    {
        // remove references
        //sock.OnClose -= Socket_OnClose;
        //sock.OnConnect -= Socket_OnConnect;
        //sock.OnReceive -= Socket_OnReceive;
        sock?.Destroy();
        //Receiver = null;
        Close();
        sock = null;

        OnClose   = null;
        OnConnect = null;
        //OnDataReceived = null;
        OnDestroy?.Invoke(this);
        OnDestroy = null;
    }
Example #26
0
    public override void TakeDamage(object sender, EventArgs e)
    {
        if (_hitpoint > 0)
        {
            _hitpoint--;
            //Debug.Log("hit");
        }
        else
        {
            // HP limiter
            _hitpoint = 0;

            // Fire up dead event
            OnDestroy?.Invoke(this, EventArgs.Empty);
            _isAlive = false;
        }
    }
Example #27
0
 public void Dispose()
 {
     Hide();
     Res.Release();
     OnClose();
     for (int i = 0; i < _subViews.Count; i++)
     {
         _subViews[i].OnClose();
     }
     Binding.Reset();
     OnDestroy?.Invoke();
     ViewModel?.OnViewDestroy();
     if (Go != null)
     {
         Object.Destroy(Go.gameObject);
     }
 }
Example #28
0
    public void OnTriggerEnter(Collider c)
    {
        if (c.gameObject.layer == 9)
        {
            Projectile projectile = c.GetComponent <Projectile>();
            Unit       shooter    = projectile.owner.GetComponent <Unit>();

            if (!isDesturcted && shooter != null && unit != null)
            {
                if (shooter == unit)
                {
                    return;
                }

                Weapon w = projectile.weapon;
                unit.hp -= (w.damage * shooter.outputDamageMultiplier) * (Mathf.Clamp((1 - unit.armor * 0.01f) * unit.inputDamageMultiplier, 0, 1));

                OnHpAmountChanged?.Invoke(this);

                /* TODO: make unit die */
                if (unit.hp <= 0)
                {
                    OnDestroy?.Invoke();
                    shooter.OnUnitDestroyed(unit);
                    GameObject effect = Instantiate(Resources.Load("Prefabs/Particle Systems/explosion_1")) as GameObject;
                    effect.transform.position = c.transform.position;
                    effect.transform.parent   = GameObject.Find("Effects").transform;
                    var agent = GetComponent <NavMeshAgent>();
                    if (agent != null)
                    {
                        agent.enabled = false;
                    }
                    isDesturcted = true;
                }
            }

            if ((projectile.penetrative && penetrable) == false)
            {
                Destroy(c.gameObject);
                GameObject effect = Instantiate(Resources.Load($"Prefabs/Particle Systems/{projectile.weapon.hitEffectName}")) as GameObject;
                effect.transform.position = c.transform.position;
                effect.transform.parent   = GameObject.Find("Effects").transform;
            }
        }
    }
Example #29
0
    public void Destroy()
    {
        Close();

        receiveNetworkBuffer = null;
        receiveCallback      = null;
        sendCallback         = null;
        sock                 = null;
        receiveBuffer        = null;
        receiveNetworkBuffer = null;
        sendBufferQueue      = null;

        //socketArgs.Completed -= SocketArgs_Completed;
        //socketArgs.Dispose();
        //socketArgs = null;
        OnDestroy?.Invoke(this);
        OnDestroy = null;
    }
Example #30
0
        public virtual void DestroyEntity()
        {
            if (IsDestroyed)
            {
                return;
            }

            // Must come before anything else to notify collision engine
            // of which components to remove from collision engine
            OnDestroy?.Invoke(this, null);

            // remove all components and child entities
            Components.ForEach(c => { c.IsActive = false; c.DetachFromEntity(); });
            ChildEntities.ForEach(c => c.DestroyEntity());

            ParentEntity = null;
            IsDestroyed  = true;
        }