Exemplo n.º 1
0
    private void OnAnimationEnd(ref AnimationInfo info)
    {
        //Look if end of state Dying
        if (info.NewState != State.Dying)
        {
            return;
        }

        if (info.Entity == GameVariables.Player.Entity)
        {
            //GlobalEvents.PlayerEvents.OnPlayerDie();
            return;
        }

        if (rnd.Next(20) == 10)
        {
            if (entityManager.HasComponent <Translation>(info.Entity))
            {
                var trans = entityManager.GetComponentData <Translation>(info.Entity);

                //Player only has a pistol
                if (GameVariables.Player.PlayerCurrentWeapons.Count <= 1)
                {
                    return;
                }

                int        index      = rnd.Next(1, GameVariables.Player.PlayerCurrentWeapons.Count);
                WeaponType weaponType = GameVariables.Player.PlayerCurrentWeapons[index];
                DropSystem.DropAmmunition(entityManager, trans.Value, weaponType);
            }
        }

        //Destroy entity
        entityManager.DestroyEntity(info.Entity);
    }
Exemplo n.º 2
0
    private void SwapAnimation(ref AnimationInfo info)
    {
        if (!entityManager.Exists(info.Entity))
        {
            return;
        }
        if (!entityManager.HasComponent <TypeData>(info.Entity))
        {
            return;
        }

        //Get Type of Entity
        TypeData type = entityManager.GetComponentData <TypeData>(info.Entity);

        //TODO CAN REMOVE UNDER IN THEORIE
        //Make sure animation exists for this type/state
        if (!AnimationHolder.Animations.ContainsKey(type.Value) ||
            !AnimationHolder.Animations[type.Value].ContainsKey(info.NewState))
        {
            return;
        }

        //Get AnimationComponent
        AnimationData animation = entityManager.GetComponentData <AnimationData>(info.Entity);

        //Set new frame
        animation.MeshIndexAt = 0;
        entityManager.SetSharedComponentData(info.Entity,
                                             AnimationHolder.Animations[type.Value][info.NewState].Frames[animation.MeshIndexAt]);

        //Set new Refresh Group
        entityManager.SetComponentData(info.Entity, animation);
        entityManager.SetSharedComponentData(info.Entity, new AnimationBatch
        {
            BatchId = AnimationSystem.BatchIdToUpdate
        });
    }