// Use this for initialization
    new void Start()
    {
        /** START Merge from Root **/
        isBackAtSpawner = true;
        PowerupFactory puf = PowerupFactory.GetPUF();

        transform.position = puf.transform.position;

        if (startReleased)
        {
            ProcessReleased();
        }
        /** END **/

        timeCreated = Time.time;
        // created with everything off
        DisablePhysicsAndRendering();
        affectedArea.DeActivate();

        Target tempMeAsTarget = this.GetComponent <Target>();

        if (tempMeAsTarget != null)
        {
            meAsTarget = tempMeAsTarget;
        }
    }
    void OnUsePowerUp(bool check)
    {
        //ToyBox.GetPandora().CommandCenter_01.pow

        bool isActive = PowerupFactory.GetPUF().ToggleFactory();

        Debug.Log("Spawner is " + isActive);
    }
Beispiel #3
0
    public void Spawn(Transform trans = null, PowerupFactory.PowerUpsDirectoryType newSpawnType = PowerupFactory.PowerUpsDirectoryType.RANDOM)
    {
        if (_active && maxSpawnCount < 0 || currSpawnCount <= maxSpawnCount)
        {
            if (PowerupFactory.GetPUF() == null)
            {
                return;
            }

            int randType = 0;


            if (newSpawnType == PowerupFactory.PowerUpsDirectoryType.RANDOM)             //spawnRandom){
            {
                randType = Random.Range(0, PowerupFactory.GetPUF().powerUpRootTypes.Count);
            }
            else
            {
                randType = (int)newSpawnType;                //(int)spawnType;
            }
//



            PowerupBase spawnPU = PowerupFactory.GetPUF().GetPowerUp((PowerupFactory.PowerUpsDirectoryType)randType);
            if (spawnPU)
            {
                // make sure its active
                spawnPU.gameObject.SetActive(true);

                // who ever triggers spawn can set it to a transform
                if (trans != null)
                {
                    spawnPU.transform.position = trans.position;
                }
                else
                {
                    spawnPU.transform.position = this.transform.position;
                }
                spawnPU.ProcessReleased();
                if (spawnPU.GetComponent <Rigidbody>())
                {
                    float randX = Random.Range(0, spawnForceX);
                    float randY = Random.Range(0, spawnForceY);
                    float randZ = Random.Range(0, spawnForceZ);
                    spawnPU.GetComponent <Rigidbody>().AddForce(randX, randY, randZ);
                }
                releasedPowerUpTime = Time.time;
                currSpawnCount++;
            }
            else
            {
                releasedPowerUpTime = 0;
            }
        }
    }
    public void ProcessBackToSpawner()
    {
        /** Merge with Root **/
        // print ("ProcessBackToSpawner");

        DisablePhysicsAndRendering();
        transform.position = PowerupFactory.GetPUF().transform.position;
        // we are no longer active, setting this flag will tell the factory to put it back to the active list
        isBackAtSpawner = true;

        /** END **/

        //DisablePhysicsAndRendering();
    }
    // Update is called once per frame
    void Update()
    {
        CheckTiming();
        if (!host && affectedArea)
        {
            // set the parent and the affect position to my rigid body, keep us together
            // position back to the factory!
            PowerupFactory puf = PowerupFactory.GetPUF();
            affectedArea.transform.localPosition.Set(puf.transform.position.x, puf.transform.position.y, puf.transform.position.z);
            affectedArea.transform.position = GetComponent <Rigidbody>().position;
        }

        if (host && affectedArea)
        {
//			if (host.rigidbody){
            //affectedArea.transform.position = host.rigidbody.position;
            //rigidbody.position = host.rigidbody.position;
            //}
            // if we have a host that means our physics body is deactive and kinetic.  we can update the position
            // updating the position of the affected area, most affective areas will
            // be locked on the positon of the bot
            if (host.transform && keepAffectedAreaOnHost)
            {
                affectedArea.transform.localPosition.Set(0.0f, 0.0f, 0.0f);
                affectedArea.transform.position = host.transform.position;

                GetComponent <Rigidbody>().position = host.transform.position;
                //rigidbody.MovePosition(host.transform.position);
            }
        }
        if (!isPickedup)
        {
            affectedArea.DeActivate();
        }
        if (meAsTarget != null)
        {
            //Debug.Log("PowerupBase Has a target!!!!!!!");
            if (this.IsDestroyed())
            {
                Debug.Log("PowerupBase Is Destroyed!!!!!");

                this.DisablePhysicsAndRendering();
                ProcessBackToSpawner();
            }
        }
    }
Beispiel #6
0
    void OnClick()
    {
        //if (spawner){
        //PowerupFactory.GetPUF().allowSpawn = !PowerupFactory.GetPUF().allowSpawn;
        bool isActive = PowerupFactory.GetPUF().ToggleFactory();

        //spawner.Toggle();
        if (myLabel)
        {
            if (isActive)
            {
                myLabel.text = "Spawner On";
            }
            else
            {
                myLabel.text = "Spawner Off";
            }
        }
        //}
    }
Beispiel #7
0
    void Start()
    {
        PowerupFactory puf = PowerupFactory.GetPUF();

        if (puf == null)
        {
            return;
        }
        bool isActive = puf.IsSpawning();

        if (myLabel)
        {
            if (isActive)
            {
                myLabel.text = "Spawner On";
            }
            else
            {
                myLabel.text = "Spawner Off";
            }
        }
    }