Inheritance: MonoBehaviour
	public void OnEnable()
	{
		_trashManTarget = target as TrashMan;
		_trashManTarget.recycleBinCollection = (target as TrashMan).recycleBinCollection;
		
		_prefabFoldouts = new List<bool>();
		if( _trashManTarget.recycleBinCollection != null )
			for( int n = 0; n < _trashManTarget.recycleBinCollection.Count; n++ )
				_prefabFoldouts.Add( true );
		
		clearNullReferences();
	}
Esempio n. 2
0
    void SpawnPlayer()
    {
        GameObject newPlayer     = TrashMan.spawn(player);
        GameObject newController = TrashMan.spawn(playerController);

        Character        playerCharacter = newPlayer.GetComponent <Character>();
        PlayerController controller      = newController.GetComponent <PlayerController>();

        playerCharacter.GetComponent <CharacterHealth>().OnDeath += HandlePlayerDeath;
        playerCharacter.GetComponent <CharacterHealth>().OnHurt  += HandlePlayerHurt;
        controller.Posses(playerCharacter);

        //this.playerCamera.target = playerCharacter.transform;
    }
Esempio n. 3
0
    public void Drop()
    {
        if (!canDrop)
        {
            return;
        }

        this.canDrop     = false;
        this.recharching = true;
        this.c_coldown   = 0;
        GameObject bomb = TrashMan.spawn("bomb", Game.Instance.player.transform.position + Vector3.down * 2);

        bombButton.interactable = false;
    }
Esempio n. 4
0
    public BlockElement Create(int meters, Block block)
    {
        if (Random.Range(0, 200) < 50 && meters > 1)
        {
            namePattern = "cookie_pattern_1";
            if (Random.Range(0, 100) < 40)
            {
                namePattern = "cookie_pattern_1";
            }
            else
            {
                namePattern = "cookie_pattern_2";
            }


            GameObject pattern = TrashMan.spawn(namePattern, block.transform.position);

            if (pattern)
            {
                int rot = Random.Range(1, 5);
                switch (rot)
                {
                case 1:
                    pattern.transform.localEulerAngles = new Vector3(0, 0, 0);
                    break;

                case 2:
                    pattern.transform.localEulerAngles = new Vector3(0, 90, 0);
                    break;

                case 3:
                    pattern.transform.localEulerAngles = new Vector3(0, 270, 0);
                    break;

                case 4:
                    pattern.transform.localEulerAngles = new Vector3(0, 180, 0);
                    break;
                }

                pattern.GetComponent <Pattern>().Initialize(block);
                return(pattern.GetComponent <BlockElement>());
            }
            else
            {
                Debug.LogError("no pudimos crear un cookie pattern");
                return(null);
            }
        }
        return(null);
    }
Esempio n. 5
0
        IEnumerator _testPool()
        {
            TrashManRecycleBin data   = new TrashManRecycleBin();
            GameObject         prefab = new GameObject();

            data.prefab = prefab;
            TrashMan.manageRecycleBin(data);
            for (int i = 0; i < 66; ++i)
            {
                var newObj = TrashMan.spawn(prefab);
                TrashMan.despawnAfterDelay(newObj, 2f);
                yield return(new WaitForSeconds(3f));
            }
        }
Esempio n. 6
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "PointSensor")
     {
         Game.Instance.AddPoint(data.value);
         GameObject sfx = TrashMan.spawn("sfx");
         sfx.GetComponent <AudioSource>().clip = clips[0];
         sfx.GetComponent <AudioSource>().Play();
         this.GetComponent <SphereCollider>().enabled = false;
         //StartCoroutine(Destruct());
         myRigidbody.AddForce(new Vector3(0, 0, 20.0f));
         //Kill();
     }
 }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        _ammo = Mathf.Clamp01(_ammo + ammoRegen * Time.deltaTime);

        if (Input.GetKey(KeyCode.Space) && Time.time > _lastShotTime + cooldown && _ammo > ammoCost)
        {
            _ammo        -= ammoCost;
            _lastShotTime = Time.time;
            InitSpeedAndTorque speedAndTorque = TrashMan.spawn(projectile, transform.position, transform.rotation).GetComponent <InitSpeedAndTorque>();
            speedAndTorque.Go();
        }

        MessageKit <float> .post(MessageIds.AMMO_LEFT, _ammo);
    }
Esempio n. 8
0
    void Update()
    {
        if (!this.waiting)
        {
            return;
        }

        this.c += Time.deltaTime;
        if (c > t)
        {
            TrashMan.despawn(this.gameObject);
            this.waiting = false;
        }
    }
    public void Die()
    {
        TrashMan.despawn(gameObject);

        AsteroidKillInfo killInfo = new AsteroidKillInfo();

        killInfo.asteroid = gameObject;
        killInfo.scale    = asteroidChildController.CurrentScale;
        MessageKit <AsteroidKillInfo> .post(MessageIds.ASTEROID_KILLED, killInfo);

        var particles = TrashMan.spawn(asteroidExplosionPrefab, transform.position).GetComponent <ParticleSystem>();

        particles.Clear();
        particles.Play();
    }
Esempio n. 10
0
	private void Awake()
	{
		if( instance != null )
		{
			Destroy( gameObject );
		}
		else
		{
			transform = gameObject.transform;
			instance = this;
			initializePrefabPools();
		}

		StartCoroutine( cullExcessObjects() );
	}
Esempio n. 11
0
    public void OnDie()
    {
        if (!enemy.isDie)
        {
            enemy.isDie = true;


            /*MoneyFly moneyfly = TrashMan.spawn("moneyFly", Game.Me.ui.mycamera.WorldToScreenPoint(this.transform.position)).GetComponent<MoneyFly>();
             * moneyfly.gameObject.transform.SetParent(Game.Me.ui.canvas.transform);
             * moneyfly.Fly();*/

            TrashMan.despawn(this.gameObject);
            Game.Me.OnEnemyDie(this.enemy);
        }
    }
    void Update()
    {
        m_count += 1 * Time.deltaTime;

        if (m_count >= m_lifetime)
        {
            m_count            = 0;
            transform.rotation = new Quaternion(0, 0, 0, 0);
            TrashMan.despawn(gameObject);
        }

        float moveDistance = m_speed * Time.deltaTime;

        transform.Translate(Vector2.up * moveDistance);
    }
Esempio n. 13
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        var playerCollider = collision.GetComponent <PlayerCollider>();

        if (playerCollider != null)
        {
            var particles = TrashMan.spawn(explosionPrefab, transform.position).GetComponent <ParticleSystem>();
            particles.Clear();
            particles.Play();

            TrashMan.despawn(gameObject);

            MessageKit <TargetCollider> .post(MessageIds.TARGET_HIT, this);
        }
    }
Esempio n. 14
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            transform = gameObject.transform;
            instance  = this;
            initializePrefabPools();
        }

        StartCoroutine(cullExcessObjects());
    }
Esempio n. 15
0
    public void drawQuardTree(QuardTree tree)
    {
        GameObject txt = TrashMan.spawn(textPrefab.gameObject);

        txt.transform.position             = new Vector3(tree.bound.center.x, tree.bound.center.y, 0);
        txt.GetComponent <TextMesh>().text = tree.objs.Count.ToString();
        dicShow.Add(txt.GetComponent <TextMesh>(), tree);
        if (tree.trees.Count > 0)
        {
            for (int i = 0; i < tree.trees.Count; i++)
            {
                drawQuardTree(tree.trees[i]);
            }
        }
    }
Esempio n. 16
0
        public void BackstabOnHit(Collider hit)
        {
            Entity entity = hit.gameObject.GetComponent <Entity>();

            if (entity != null)
            {
                if ((owner.enemyFactions & entity.currentFaction) == entity.currentFaction)
                {
                    owner.OnHit(entity, damage * backstabMultiplier);
                    entity.Damage(owner, damage * backstabMultiplier);

                    TrashMan.spawn(backstabHitPrefab, entity.transform.position, Quaternion.identity);
                }
            }
        }
Esempio n. 17
0
        public void TakeDamage(int damage)
        {
            if (isInvulerable)
            {
                return;
            }

            if (this.freezeTimeOnHit)
            {
                GameManager.instance.FreezeTime();
            }

            this.health -= damage;

            if (this.OnHurt != null)
            {
                this.OnHurt(this.character);
            }

            if (this.health <= 0)
            {
                this.health = 0;
                this.StopAllCoroutines();

                if (this.spawnOnDeath)
                {
                    TrashMan.spawn(this.spawnOnDeath, this.transform.position);
                }

                if (this.OnDeath != null)
                {
                    this.OnDeath(this.character);
                }
            }
            else
            {
                this.StartCoroutine(this.Flash());
                if (this.invulnerabilityTimer > 0)
                {
                    this.StartCoroutine(this.Invulerable());
                }

                if (this.hurt)
                {
                    this.source.PlayOneShot(this.hurt);
                }
            }
        }
Esempio n. 18
0
    public void OnEnable()
    {
        _trashManTarget = target as TrashMan;
        _trashManTarget.recycleBinCollection = (target as TrashMan).recycleBinCollection;

        _prefabFoldouts = new List <bool>();
        if (_trashManTarget.recycleBinCollection != null)
        {
            for (int n = 0; n < _trashManTarget.recycleBinCollection.Count; n++)
            {
                _prefabFoldouts.Add(true);
            }
        }

        clearNullReferences();
    }
Esempio n. 19
0
        public virtual void ShootProjectile()
        {
            if (projectilePrefab != null)
            {
                OnCast();
                var pro = TrashMan.spawn(projectilePrefab, owner.transform.position + (projectileOffset * owner.transform.forward) + (0.4f * owner.transform.up),
                                         owner.transform.rotation);

                Projectile proj = pro.GetComponent <Projectile>();
                if (proj != null)
                {
                    proj.Initialize(owner, owner.enemyFactions);
                    proj.damage = damage;
                }
            }
        }
        // when the projectile can pierce
        public virtual void OnTriggerEnter(Collider collision)
        {
            Entity entity = collision.gameObject.GetComponent <Entity>();

            if (entity != null)
            {
                if ((targetFaction & entity.currentFaction) == entity.currentFaction)
                {
                    OnHit(entity);
                    if (!piercing)
                    {
                        TrashMan.despawn(gameObject);
                    }
                }
            }
        }
Esempio n. 21
0
        // when the projectile can pierce
        public override void OnTriggerEnter(Collider collision)
        {
            Entity entity = collision.gameObject.GetComponent <Entity>();

            if (entity != null)
            {
                if ((owner.enemyFactions & entity.currentFaction) == entity.currentFaction)
                {
                    OnHit(entity);
                    if (Onehit)
                    {
                        TrashMan.despawn(gameObject);
                    }
                }
            }
        }
Esempio n. 22
0
    public void shoot()
    {
        GameObject obj = TrashMan.spawn("Bullet");

        obj.tag = ObjectType.EnemyBullet;
        BulletView bulletView = obj.GetComponent <BulletView>();

        obj.transform.parent   = shooter.transform.parent;
        obj.transform.position = shooter.transform.position;
        BulletLeftRunner bulletLeftRunner = new BulletLeftRunner();
        Rectangle        body             = new Rectangle(shooterPos.origin.x, shooterPos.origin.y, 20, 20);

        NetScene.getInstance().collisionTree.Insert(body);
        bulletView.SetRunner(body);
        bulletView.valid = true;
    }
Esempio n. 23
0
    void Eat()
    {
        if (kill)
        {
            return;
        }
        kill = true;
        DataManager.Instance.AddCoin();

        AudioSource audioso = TrashMan.spawn("sfx").GetComponent <AudioSource>();

        audioso.clip = audioclip;
        audioso.Play();

        Kill();
    }
        public override void ShootProjectile()
        {
            if (projectilePrefab != null)
            {
                OnCast();
                var pro = TrashMan.spawn(projectilePrefab, owner.transform.position + (projectileOffset * owner.transform.forward) + (0.4f * owner.transform.up),
                                         owner.transform.rotation);

                Projectile proj = pro.GetComponent <Projectile>();
                if (proj != null)
                {
                    proj.damage = damage * (1 + damageMultiplier * (chargeTime / maxChargeTime));
                    proj.speed  = baseSpeed + speedMultiplier * chargeTime / maxChargeTime;
                    proj.Initialize(owner, owner.enemyFactions);
                }
            }
        }
        public override void RaiseEvent(string eventName)
        {
            switch (eventName)
            {
            case "Skill1_Sparks":
                Instantiate(SparksPrefab, owner.transform.position, Quaternion.identity);
                break;

            case "Skill1_Shield":
                var           shieldGO = TrashMan.spawn(TempestShieldPrefab, owner.transform.position, Quaternion.identity);
                TempestShield tshield  = shieldGO.GetComponent <TempestShield>();
                tshield.damage   = damage;
                tshield.lifeSpan = duration;
                tshield.Initialize(owner, owner);
                break;
            }
        }
        public override void RaiseEvent(string eventName)
        {
            switch (eventName)
            {
            case "Attack_Shoot":
                ShootProjectile();
                break;

            case "Attack_Kick":
                var bombGO = TrashMan.spawn(KickBomb, owner.transform.position + 1 * owner.transform.forward,
                                            Quaternion.identity);
                Bomb bomb = bombGO.GetComponent <Bomb>();
                bomb.damage = damage;
                bomb.Initialize(owner, owner.enemyFactions);
                break;
            }
        }
Esempio n. 27
0
 private void movePlatform()
 {
     if (ComboManager.gameRunning)
     {
         if (gameObject.transform.position.z < 12)
         {
             //move the platform towards left
             gameObject.transform.position += new Vector3(0, 0, Time.deltaTime * platformMovementSpeed);
         }
         else
         {
             //destroy the platform
             TrashMan.despawn(this.gameObject);
             Debug.Log("Destroyed this platform");
         }
     }
 }
Esempio n. 28
0
    public override void OnInitialize()
    {
        this.transform.localRotation = Quaternion.Euler(new Vector3(90, 0, 0));


        if (Random.Range(0, 100) < 50 && Game.Instance.fallDistanceMeter.meters > 30)
        {
            int num = Random.Range(0, 4);
            for (int i = 0; i < num; i++)
            {
                GameObject cueton = TrashMan.spawn("cueton", positions[i].position);
                block.blockElements.Add(cueton.GetComponent <BlockElement>());
            }
        }

        base.OnInitialize();
    }
Esempio n. 29
0
    public void OnClick()
    {
        if (PowerupMan.Me.SubstractCono())
        {
            Vector3 ini = new Vector3(-2, -6, 0);

            for (int i = 0; i < spa.Count; i++)
            {
                Bullet b = TrashMan.spawn("cono", ini + spa[i]).GetComponent <Bullet>();
                b.Initialize();
            }
        }



        counterTxt.text = "" + PowerupMan.Me.numConos;
    }
Esempio n. 30
0
    //Função para a colisão da bala com o player
    void OnTriggerEnter2D(Collider2D c)
    {
        Player damageableObject = c.GetComponent <Player>();

        //Se a tag do inimigo estiver como verde e como este projétil é o vermelho, então o dano deve ser causado. Função CamShake utilizada pra sacudir a tela
        if (damageableObject != null && damageableObject.tag == "green")
        {
            TrashMan.spawn("Hit_Red", gameObject.transform.position, gameObject.transform.rotation);
            cam.Shake(0.5f, 0.3f, 3f);
            damageableObject.takeDamage(damage);
        }
        //Se a tag for verde, então spawnar o efeito visual de absorção e despawnar a bala.
        if (damageableObject != null && damageableObject.tag == "red")
        {
            TrashMan.spawn("Hit_Absorbed_Red", damageableObject.transform.position, damageableObject.transform.rotation);
            updateScore();
        }
    }
Esempio n. 31
0
        public override void ActivateDown()
        {
            if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Locomotion"))
            {
                return;
            }

            if (!IsDisabled)
            {
                IsDisabled = true;
                OnCast();
                var        fireEssenceGo = TrashMan.spawn(iceEssensePrefab, owner.transform.position, Quaternion.identity);
                IceEssence fe            = fireEssenceGo.GetComponent <IceEssence>();
                fe.bombDamage   = bombDamage;
                fe.stunDuration = stunDuration;
                fe.Initialize(owner);
            }
        }
Esempio n. 32
0
    public void EatLotCookie(LotCookie lotCookie)
    {
        this.economyMan.AddLotCookiesFromFalling(1);
        lotCookie.OnEat();
        GameObject p = TrashMan.spawn("eat_loot_cookie", this.transform.position);

        p.transform.eulerAngles = new Vector3(-90, 0, 0);
        p.GetComponent <ParticleSystem>().Play();

        for (int i = 0; i < reportOnLotCookies.Count; i++)
        {
            if (this.reportOnLotCookies[i] == EconomyMan.Instance.LotCookiesThisGame)
            {
                this.reportOnLotCookies.RemoveAt(i);
                EventsMan.Instance.Call_OnEatNSpecialCookies(EconomyMan.Instance.LotCookiesThisGame);
            }
        }
    }
Esempio n. 33
0
	private void Awake()
	{
		if( instance != null )
		{
			Destroy( gameObject );
		}
		else
		{
			transform = gameObject.transform;
			instance = this;
			initializePrefabPools();

			if( persistBetweenScenes )
				DontDestroyOnLoad( gameObject );
		}

		// only cull if we have an interval greater than 0
		if( cullExcessObjectsInterval > 0 )
			StartCoroutine( cullExcessObjects() );
	}
Esempio n. 34
0
	private void OnApplicationQuit()
	{
		instance = null;
	}
Esempio n. 35
0
    private void OnDestroy()
    {
        // i need to get all the recycle bins associated with this TrashMan instance.
        // ah, thats just the recyclebincoll!
        for(int i = recycleBinCollection.Count; i > 0; i--)
        {
            if(recycleBinCollection[i-1].prefab == null) continue;
            TrashMan.removeRecycleBin(recycleBinCollection[i-1].prefab);
        }

        if(TrashMan.instance == this)
        {
            // we have to reassign!
            TrashMan[] tm = GameObject.FindObjectsOfType<TrashMan>();
            foreach(var ins in tm)
            {
                if(ins != this)
                {
                    Debug.Log("Reassigning TrashMan.instance...", ins.gameObject);
                    TrashMan.instance = ins;
                    TrashMan.instance.transform = ins.gameObject.transform;
                    break;
                }
            }
        }
    }
 private void Awake()
 {
     _boardView = GetComponent<BoardView>();
     _boardGridField = GetComponent<BoardGridField>();
     _pool = GetComponent<TrashMan>();
 }