Beispiel #1
0
 public static void OnEntityDestroyed(DestroyEvent de)
 {
     if (de.Attacker != null && de.Entity != null && !de.IsDecay)
     {
         if (((Fougerite.Player)de.Attacker).UID == de.Entity.UOwnerID)
         {
             return;
         }
         if ((de.WeaponName.ToLower().Contains("explosive") || de.WeaponName.ToLower().Contains("grenade") ||
              de.WeaponName.ToLower().Contains("hatchet") || de.WeaponName.ToLower().Contains("axe") ||
              de.WeaponName.ToLower().Contains("rock")) && (de.Entity.Name.ToLower().Contains("wall") ||
                                                            de.Entity.Name.ToLower().Contains("door")))
         {
             Fougerite.Entity entity = de.Entity;
             OwnerTimeData[entity.UOwnerID] = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds;
             //DataStore.GetInstance().Add("LegitRaidA", ((Fougerite.Player)de.Attacker).UID, true);
             if (RaiderTime.ContainsKey(entity.UOwnerID))
             {
                 if (MaxRaidTime < RaiderTime[entity.UOwnerID] + RaidTime)
                 {
                     RaiderTime[entity.UOwnerID] = MaxRaidTime;
                     return;
                 }
                 RaiderTime[entity.UOwnerID] = RaiderTime[entity.UOwnerID] + RaidTime;
             }
             else
             {
                 RaiderTime[entity.UOwnerID] = RaidTime;
             }
         }
     }
 }
 public void Destroy()
 {
     GameManager.ObjectSpawner.Destroy(actor);
     Inventory = null;
     actor     = null;
     DestroyEvent?.Invoke(this);
 }
Beispiel #3
0
 private void OnMouseDown()
 {
     GameManager.AddScore(GetScore(1 - _lifeTime / _destroyTime));
     GameManager.Instance.PlaySound(DestroySound);
     DestroyEvent?.Invoke(this);
     Destroy();
 }
Beispiel #4
0
        public void Destroy()
        {
            if (IsDestroyed)
            {
                return;
            }

            IsDestroyed = true;

            DestroyEvent?.Invoke(this);

            foreach (EntityComponent component in _components)
            {
                RemoveEntityComponent(component, false);
            }

            _removingComponents.Clear();
            _removingComponents = null;

            _disabledComponents.Clear();
            _disabledComponents = null;

            _components.Clear();
            _components = null;

            AddedComponentEvent   = null;
            RemovedComponentEvent = null;
        }
Beispiel #5
0
        public void GetEventTest()
        {
            DataRepository dataRepository = new DataRepository(new AutoFillFull());

            Assert.AreEqual(dataRepository.GetAllEvents().Count, 3);

            Product product = new Product
            {
                Id          = Guid.NewGuid(),
                Name        = "TestName",
                Description = "TestDescription"
            };

            Client client = new Client
            {
                Id       = Guid.NewGuid(),
                Birthday = new DateTime(),
                Email    = "*****@*****.**",
                LastName = "LastName",
                Name     = "Name"
            };

            Guid testId = Guid.NewGuid();

            Event destroyEvent = new DestroyEvent(testId, client, new ItemStatus(product, 10f, 10f, 10), "example");

            dataRepository.AddEvent(destroyEvent);
            Assert.IsTrue(dataRepository.GetAllEvents().Contains(destroyEvent));
            Event getEvent = dataRepository.GetEvent(testId);

            Assert.AreEqual(getEvent, destroyEvent);
        }
    void OnHit(float damage, Transform hitTransform)
    {
        if (hitTransform == transform)
        {
            currentHealth -= damage;
            if (currentHealth > 0f)
            {
                HitEvent.Invoke(this);
            }
        }

        if (currentHealth <= 0f)
        {
            if (explosionObject != null)
            {
                GameObject explosion = Instantiate(explosionObject);
                explosion.transform.position = transform.position;
            }

            SoundManager.instance.PlaySound(explosionSound);

            if (DestroyEvent != null)
            {
                DestroyEvent.Invoke(this);
            }

            OnDestroy();
        }
    }
Beispiel #7
0
 /// <summary>
 /// 销毁用户控件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_Destroy(object sender, RoutedEventArgs e)
 {
     if (DestroyEvent != null)
     {
         _backData.Timer.Remove(GetValue);
         DestroyEvent.Invoke(_model.ID);
     }
 }
Beispiel #8
0
        private IEnumerator DestroyCoroutine()
        {
            yield return(new WaitForSeconds(_destroyTime));

            GameManager.AddScore(GetScore(1) * -1);
            GameManager.Instance.PlaySound(DestroySound);
            DestroyEvent?.Invoke(this);
            Destroy();
        }
Beispiel #9
0
        public static void EntityHurt(object entity, ref DamageEvent e)
        {
            Contract.Assume(entity != null);

            try
            {
                HurtEvent he = new HurtEvent(ref e, new Entity(entity));
                if (decayList.Contains(entity))
                {
                    he.IsDecay = true;
                }

                if (he.Entity.IsStructure() && !he.IsDecay)
                {
                    StructureComponent component = entity as StructureComponent;
                    if ((component.IsType(StructureComponent.StructureComponentType.Ceiling) || component.IsType(StructureComponent.StructureComponentType.Foundation)) || component.IsType(StructureComponent.StructureComponentType.Pillar))
                    {
                        he.DamageAmount = 0f;
                    }
                }
                TakeDamage takeDamage = he.Entity.GetTakeDamage();
                takeDamage.health += he.DamageAmount;

                // when entity is destroyed
                if (e.status != LifeStatus.IsAlive)
                {
                    DestroyEvent de = new DestroyEvent(ref e, new Entity(entity), he.IsDecay);
                    if (OnEntityDestroyed != null)
                    {
                        OnEntityDestroyed(de);
                    }
                }
                else if (OnEntityHurt != null)
                {
                    OnEntityHurt(he);
                }

                Zone3D zoned = Zone3D.GlobalContains(he.Entity);
                if ((zoned == null) || !zoned.Protected)
                {
                    if ((he.Entity.GetTakeDamage().health - he.DamageAmount) <= 0f)
                    {
                        he.Entity.Destroy();
                    }
                    else
                    {
                        TakeDamage damage2 = he.Entity.GetTakeDamage();
                        damage2.health -= he.DamageAmount;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
 public void Awake()
 {
     DeathEvent       = new DeathEvent();
     PickupEvent      = new PickupEvent();
     HPChangeEvent    = new HPChangeEvent();
     HPReduceEvent    = new HPChangeEvent();
     HPRecoverEvent   = new HPChangeEvent();
     ReviveEvent      = new ReviveEvent();
     DestroyEvent     = new DestroyEvent();
     MainPlayerAttack = new MainPlayerAttackEvent();
 }
Beispiel #11
0
        // Example

        public void OnEntityDestroy(DestroyEvent de)
        {
            Entity entity = de.Entity;

            Fougerite.Player attacker = (Fougerite.Player)de.Attacker;
            //Getting the entity ownername using PlayerDatabase + owner doesnt have to be online

            string ownername = PlayerDatabase.GetNameFromID(entity.OwnerID);

            attacker.Message(ownername + " is the owner of this structure");
        }
Beispiel #12
0
 public void DestroyOnPickUp()
 {
     if (entity.IsOwner)
     {
         BoltNetwork.Destroy(this.gameObject);
     }
     else
     {
         var evnt = DestroyEvent.Create(state.MyOwner, EntityTargets.Everyone);
         evnt.EntityDestroy = entity;
         evnt.Send();
     }
 }
Beispiel #13
0
        public async Task <Result <Event> > GetEvent(DestroyEvent request)
        {
            Maybe <Event> maybeEvent = await _eventRepository.FindById(request.Id);

            if (maybeEvent.HasNoValue)
            {
                return(Result.Failure <Event>("Event does not exist"));
            }

            Event @event = maybeEvent.Value;

            return(Result.Success(@event));
        }
Beispiel #14
0
    public virtual void Dead(OmniObject attacker)
    {
        stateTime = 0;
        stun = 10;
        rotSpeed = 900;

        if (!Respawnable)
        {
            DestroyEvent e = new DestroyEvent(OmniWorld.tick+10);
            e.objid = id;
            stateTime = 0;
            OmniEvents.AddEvent(e);
        }
    }
Beispiel #15
0
 private void Update()
 {
     if (Time.time - startTime > time && time > 0)
     {
         if (TimeoutEvent != null)
         {
             TimeoutEvent.Invoke(this, parentWeapon);
         }
         Destroy(this.gameObject, 0.4f);
         if (DestroyEvent != null)
         {
             DestroyEvent.Invoke(this);
         }
     }
 }
Beispiel #16
0
 public void DestroyPillier()
 {
     //Seed s = BoltNetwork.Instantiate(BoltPrefabs.Seed, this.seedDrop.position, Quaternion.identity).GetComponent<Seed>();
     //s.Init(0, null, Quaternion.identity, false, myOwner, state.MyColor, this.currentDir);
     if (entity.IsOwner)
     {
         BoltNetwork.Destroy(this.gameObject);
     }
     else
     {
         var evnt = DestroyEvent.Create(state.MyOwner, EntityTargets.Everyone);
         evnt.EntityDestroy = entity;
         evnt.Send();
     }
     this.myOwner.GetComponent <Guardian>().RemovePillier(this);
 }
Beispiel #17
0
    void Update()
    {
        airTime += Time.deltaTime;
        if (airTime >= maxAirTime)
        {
            DestroyEvent?.Invoke();
            Destroy(gameObject);
        }

        var newPos = myTransform.position;

        newPos.x += Time.deltaTime * projectileData.dir.x * projectileData.speed;
        newPos.y += Time.deltaTime * projectileData.dir.y * projectileData.speed;

        myTransform.position = newPos;
    }
        public async Task When_The_Event_Does_Not_Exist_Should_Return_Failure()
        {
            var eventRepository = new Mock <IEventRepository>();

            Maybe <Event> maybeEvent = null;

            eventRepository.Setup(it => it.FindById(It.IsAny <Guid>())).Returns(Task.FromResult(maybeEvent));

            var destroyEvent = new DestroyEvent(Guid.NewGuid());

            var handler = new DestroyEventHandler(eventRepository.Object);

            Result result = await handler.Handle(destroyEvent, CancellationToken.None);

            Assert.True(result.IsFailure);
        }
        public async Task Should_Return_Success()
        {
            var eventRepository = new Mock <IEventRepository>();

            Maybe <Event> maybeEvent = new Event(Guid.NewGuid(), "Christmas", new DateTime(year: 2020, month: 6, day: 25));

            var destroyEvent = new DestroyEvent(Guid.NewGuid());

            eventRepository.Setup(it => it.FindById(It.IsAny <Guid>())).Returns(Task.FromResult(maybeEvent));

            var handler = new DestroyEventHandler(eventRepository.Object);

            Result result = await handler.Handle(destroyEvent, CancellationToken.None);

            Assert.True(result.IsSuccess);
        }
Beispiel #20
0
        public async Task <Result <Event> > Handle(DestroyEvent request, CancellationToken cancellationToken)
        {
            Result <Event> eventResult = await GetEvent(request);

            if (eventResult.IsFailure)
            {
                return(Result.Failure <Event>(eventResult.Error));
            }

            eventResult = await RemoveEvent(eventResult.Value);

            if (eventResult.IsFailure)
            {
                return(Result.Failure <Event>(eventResult.Error));
            }

            return(Result.Success(eventResult.Value));
        }
        public async Task When_The_Event_Is_Not_Removed_Should_Return_Failure()
        {
            var eventRepository = new Mock <IEventRepository>();

            Maybe <Event> maybeEvent = new Event(Guid.NewGuid(), "Christmas", new DateTime(year: 2020, month: 6, day: 25));

            eventRepository.Setup(it => it.FindById(It.IsAny <Guid>())).Returns(Task.FromResult(maybeEvent));

            eventRepository.Setup(it => it.Remove(It.IsAny <Event>())).Returns(Task.FromResult(Result.Failure("Something has gone wrong...")));

            var destroyEvent = new DestroyEvent(Guid.NewGuid());

            var handler = new DestroyEventHandler(eventRepository.Object);

            Result result = await handler.Handle(destroyEvent, CancellationToken.None);

            Assert.True(result.IsFailure);
        }
Beispiel #22
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (!projectileData.ownedByPlayer && other.gameObject.layer == enemyCollisionLayerMask)
        {
            return;
        }

        if (other.gameObject.layer == projectileLayerMask)
        {
            return;
        }

        if (other.gameObject.layer != playerLayerMask && other.gameObject.layer != defaultLayerMask)
        {
            DestroyEvent?.Invoke();
            Destroy(gameObject);
        }
    }
Beispiel #23
0
        protected override void OnDestroy()
        {
            allInstances.Remove(this);

            if (updateTimer != null)
            {
                updateTimer.Dispose();
                updateTimer = null;
            }

            DestroyEvent?.Invoke(this);

            DestroyRenderTarget();

            //!!!!
            //WinFormsAppWorld.renderTargetUserControls.Remove( this );

            base.OnDestroy();
        }
        void AddEvent(Client client, Status status, string description, Type type)
        {
            Event eventToAdd;

            if (type == typeof(DestroyEvent))
            {
                eventToAdd = new DestroyEvent(new Guid(), client, status, description);
                _dataRepository.AddEvent(eventToAdd);
            }
            else if (type == typeof(SellEvent))
            {
                eventToAdd = new SellEvent(new Guid(), client, status, description);
                _dataRepository.AddEvent(eventToAdd);
            }
            else if (type == typeof(BuyEvent))
            {
                eventToAdd = new BuyEvent(new Guid(), client, status, description);
                _dataRepository.AddEvent(eventToAdd);
            }
        }
Beispiel #25
0
    void IEcsUpdateSystem.Update()
    {
        _snakeCollider = _world.GetComponent <ColliderComponent> (_snakeObjects.Entities[0], _colliderComponentId);
        SnakeComponent snakeComponent = _world.GetComponent <SnakeComponent> (_snakeObjects.Entities[0], _snakeComponentId);

        foreach (var entity in _collisionObjects.Entities)
        {
            var eCollider = _world.GetComponent <ColliderComponent> (entity, _colliderComponentId);
            if (eCollider.Collider.bounds.Intersects(_snakeCollider.Collider.bounds))
            {
                snakeComponent.Length++;
                _world.PublishEvent <int> (snakeComponent.Length);
                var dData = new DestroyEvent();
                dData.Index = entity;
                _world.PublishEvent <DestroyEvent> (dData);
                var sData = new SpawnEvent();
                sData.Length = snakeComponent.Length;
                _world.PublishEvent <SpawnEvent> (sData);
            }
        }
    }
Beispiel #26
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.TryGetComponent(out Bullet bullet))
        {
            Destroy(gameObject);
            Destroy(bullet.gameObject);
            Instantiate(destructionEffectPrefab, transform.position, transform.rotation);

            if (DestroyEvent != null)
            {
                DestroyEvent.Invoke();
            }

            if (smallerAsteroid != null)
            {
                for (int i = 0; i < amountToSpawn; i++)
                {
                    Instantiate(smallerAsteroid, transform.position, Quaternion.identity);
                }
            }
        }
    }
Beispiel #27
0
        public async Task <IActionResult> Destroy(Guid id)
        {
            var destroyEvent = new DestroyEvent(id);

            Result <Event> result = await _mediator.Send(destroyEvent);

            if (result.IsFailure)
            {
                TempData["Failure"] = result.Error;

                return(RedirectToAction("Index", "Event"));
            }

            TempData["Success"] = "The countdown for the event has been stopped";

            _uow.Commit();

            string userId = _userManager.GetUserId(User);

            await _eventHub.Clients.User(userId).Stop(result.Value);

            return(RedirectToAction("Index", "Event"));
        }
Beispiel #28
0
    private void OnCollisionEnter(Collision collision)
    {
        var go       = collision.gameObject;
        var hurtable = go.GetComponent <Hurtable>();

        if (hurtable != null)
        {
            if (parentWeapon == null)
            {
                Debug.LogWarning("Parent weapon of projectile " + gameObject.name + " is null");
            }
            hurtable.Damaged(damage, (parentWeapon != null?parentWeapon.parent:null), parentWeapon);
            Hitted(go);
        }
        if (DestroyEvent != null)
        {
            DestroyEvent.Invoke(this);
        }
        if (destroyOnHit)
        {
            Destroy(this.gameObject, 0.1f);
        }
    }
Beispiel #29
0
 public void OnEntityDestroyed(DestroyEvent evt)
 {
     this.Invoke("On_EntityDestroyed", new object[] { evt });
 }
Beispiel #30
0
 private void OnDestroy()
 {
     DestroyEvent.Invoke();
 }
Beispiel #31
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     OmniSaveManager.Save(connectedClients[player]);
     Debug.Log("Player disconnected");
     DestroyEvent e = new DestroyEvent(OmniWorld.tick);
     e.objid = connectedClients[player].id;
     OmniEvents.AddEvent(e);
     connectedClients.Remove(player);
     NetworkView[] views = GetComponents<NetworkView>();
     for (int i = 0; i < views.Length; i++)
     {
         if (views[i].owner == player)
             GameObject.Destroy(views[i]);
     }
 }
Beispiel #32
0
    public override void OmniUpdate(float delta)
    {
        if (!Network.isClient)
        {
            if (projTimer >= 30)
            {
                DestroyEvent e = new DestroyEvent(OmniWorld.tick);
                e.objid = id;
                return;
            }
        }

        if (isProjectile)
        {
            animType = OmniAnimation.Type.Skeleton;
            projTimer += delta;
        }
        else
        {
            animType = item.animList[0].animationType;
        }

        if (spawned)
        {

                Move(delta);

            /*
                if ((movementMask &( 1 << MovementFlags.Mounted)) != 0)
                {
                    if (mountedTo.updateTick == OmniWorld.tick)
                    {
                        bounds.x = mountedTo.bounds.x;
                        bounds.y = mountedTo.bounds.y;
                        lastPos.x = mountedTo.lastPos.x;
                        lastPos.y = mountedTo.lastPos.y;
                        updateMask |= 1 << ObjectNetworkUpdate.Position;
                    }
                }
            */

                if (lastPos.x != bounds.x || lastPos.y != bounds.y)
                    updateMask |= 1 << ObjectNetworkUpdate.Position;

            lerpFrom.x = lerpTo.x;
            lerpFrom.y = lerpTo.y;

            lerpTo.x = bounds.x;
            lerpTo.y = bounds.y;
            lerpCounter = 0;

            if (isProjectile)
                if (!grounded)
                    rotation = (Mathf.Atan2(vel.y, vel.x) * Mathf.Rad2Deg) + item.animList[0].RotationOffset - 90;
        }
        base.OmniUpdate(delta);
    }
Beispiel #33
0
 public void RegisterDestroyEvent(DestroyEvent e)
 {
     m_DestroyEvents += e;
 }