Exemple #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if ((other.tag != "Enemy") && (other.tag != "Liver") && (other.tag != "Explosion") && (other.tag != "Bonus"))
     {
         ShieldComponent shield = gameObject.GetComponent <ShieldComponent>();
         if (shield != null)
         {
             if (shield.shieldLife <= 0)
             {
                 GameManager.Instance.setChangeScore(ENEMY_COINS);
                 Instantiate(explosion, transform.position, transform.rotation);
                 Destroy(other.gameObject);
                 Destroy(gameObject);
             }
             else
             {
                 shield.shieldLife--;
                 Destroy(other.gameObject);
             }
         }
         else
         {
             tempBonusVer = Random.Range(0f, 100f);
             if (BONUS_VER >= tempBonusVer)
             {
                 Instantiate(bonusSpeedShootPrefabs, transform.position, transform.rotation);
                 Debug.Log("Bonus");
             }
             GameManager.Instance.setChangeScore(ENEMY_COINS);
             Instantiate(explosion, transform.position, transform.rotation);
             Destroy(other.gameObject);
             Destroy(gameObject);
         }
     }
 }
Exemple #2
0
        public void SetShield(ShieldType shieldType, float secs)
        {
            if (shieldComponent != null)
            {
                ParentScene.RemoveObject(shieldComponent);
                shieldComponent = null;
            }

            if (shieldComponentFront != null)
            {
                ParentScene.RemoveObject(shieldComponentFront);
                shieldComponentFront = null;
            }

            if (shieldType == ShieldType.None)
            {
                shieldTime = 0f;
                return;
            }

            shieldTime = secs * Time.FramesPerSecond;

            switch (shieldType)
            {
            case ShieldType.Fire:
                shieldComponent = new ShieldComponent(shieldType, false);
                shieldComponent.OnAttach(new ActorInstantiationDetails {
                    Api = api
                });
                shieldComponent.Parent = this;

                shieldComponentFront = new ShieldComponent(shieldType, true);
                shieldComponentFront.OnAttach(new ActorInstantiationDetails {
                    Api = api
                });
                shieldComponentFront.Parent = this;
                break;

            case ShieldType.Water:
                shieldComponentFront = new ShieldComponent(shieldType, true);
                shieldComponentFront.OnAttach(new ActorInstantiationDetails {
                    Api = api
                });
                shieldComponentFront.Parent = this;
                break;

            case ShieldType.Lightning:
                // ToDo
                break;

            case ShieldType.Laser:
                // ToDo
                break;
            }
        }
Exemple #3
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Debug.LogWarning("Multiple Player classes found in scene. There can only be one");
            Destroy(gameObject);
            return;
        }

        moveComponent   = GetComponent <MoveComponent>();
        jumpComponent   = GetComponent <PlayerJumpComponent>();
        shieldComponent = GetComponent <ShieldComponent>();
    }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        // Call methods on 'dstManager' to create runtime components on 'entity' here. Remember that:
        //
        // * You can add more than one component to the entity. It's also OK to not add any at all.
        //
        // * If you want to create more than one entity from the data in this class, use the 'conversionSystem'
        //   to do it, instead of adding entities through 'dstManager' directly.
        //
        // For example,
        //   dstManager.AddComponentData(entity, new Unity.Transforms.Scale { Value = scale });
        var data = new ShieldComponent()
        {
            shieldOn = shieldOn
        };

        dstManager.AddComponentData(entity, data);
    }
Exemple #5
0
 private void Start()
 {
     shieldComponent = Player.Instance.GetComponent <ShieldComponent>();
 }