Beispiel #1
0
    /// <summary>
    /// This Method Grabs us a Fruit from the pool puts it in position and activates it.  This method is
    /// called from the "LoadAndFireRandomFruit()"
    /// </summary>
    /// <returns></returns>
    public GameObject RetrieveFruitFromPool()
    {
        //new int named r get assigned a Random value between zero and the length of the array of objectPoolScript
        int r = Random.Range(0, fruitPoolScripts.Length);
        //objectPoolScript named tempPool gets accesses the elements in the array at position R
        ObjectPoolScript tempPool = fruitPoolScripts[r];
        //new GameObject named obj and it calls GetPooledObejct on the tempPool.
        GameObject obj = tempPool.GetPooledObject();

        //if obj is null..
        if (obj == null)
        {
            //we return null...
            return(null);
        }

        //we set obj at our position...
        obj.transform.position = transform.position;
        //we set obj's rotation to 000
        obj.transform.rotation = Quaternion.identity;
        //set the obj to active
        obj.SetActive(true);
        //then return the obj
        return(obj);
    }
Beispiel #2
0
    void MultiTurtleCreator(int turtles, string type1, string type2, float posX, float startY, float scale)
    {
        for (int i = 0; i < turtles; i++)
        {
            if (Random.value > 0.5f)
            {
                turtlePool = TurtDecoder(type1);
            }
            else
            {
                turtlePool = TurtDecoder(type2);
            }

            turtle = turtlePool.GetPooledObject();
            turtle.SetActive(true);
            turtle.transform.position = new Vector3(posX, startY, -1);

            if (Random.value > 0.5f)
            {
                turtle.transform.Rotate(new Vector3(0, 180, 0));
                //turtle.transform.localScale += new Vector3 (-1, 0, 0);
            }


            turtle.transform.localScale += new Vector3(scale, scale, 0);

            AddTurtle(1);
        }
    }
Beispiel #3
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerSachelShrap").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
 }
    //GameObject flight;

    void Awake()
    {
        objPool = GameObject.Find("GameManager").GetComponent <ObjectPoolScript>();
        GetComponent <AudioSource>().volume = ValueDeliverScript.fxSound;

        characterSpeakManagerScript = GameObject.Find("CharacterSpeakManager").GetComponent <CharacterSpeakManagerScript>();
    }
Beispiel #5
0
    public void ExplodeTarget(Collider target)
    {
        OnDieAction();

        Instantiate(gameSettings.Explosion, target.transform.position, target.transform.rotation);
        ObjectPoolScript.Despawn(target.gameObject);
    }
Beispiel #6
0
    void Start()
    {
        pController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

        pinkColliderGameObjects.AddRange(GameObject.FindGameObjectsWithTag("PinkCollider"));
        purpleColliderGameObjects.AddRange(GameObject.FindGameObjectsWithTag("PurpleCollider"));
        tealColliderGameObjects.AddRange(GameObject.FindGameObjectsWithTag("TealCollider"));
        yellowColliderGameObjects.AddRange(GameObject.FindGameObjectsWithTag("YellowCollider"));
        obstacleObjects.AddRange(GameObject.FindGameObjectsWithTag("ObstacleObject"));

        numOfObstacles           = obstacleObjects.Count;
        publicObstacleObjectList = new List <GameObject>();

        for (int i = 0; i < numOfObstacles; i++)
        {
            GameObject obj = obstacleObjects[i];
            publicObstacleObjectList.Add(obj);
            obj.SetActive(false);
        }

        starPool        = GameObject.FindGameObjectWithTag("StarPool");
        colorChangePool = GameObject.FindGameObjectWithTag("ColorChangePool");

        starPoolScript        = starPool.GetComponent <ObjectPoolScript>();
        colorChangePoolScript = colorChangePool.GetComponent <ObjectPoolScript>();

        publicObstacleObjectList.Sort(SortByName);

        IncrementObstacleProgression();
        IncrementObstacleProgression();

        ChangeColorColliderState();
    }
Beispiel #7
0
	// Use this for initialization
	void Start () 
	{
		//set stuff to be changed
		Body = body.GetComponent<SpriteRenderer> ();
		Head = head.GetComponent<SpriteRenderer> ();
		full = GetComponent<Transform> ();
		Laser = GameObject.Find ("PoolLasers").GetComponent<ObjectPoolScript>();
	}
Beispiel #8
0
    public List <GameObject> pooledObjects;     //the list that will hold all of our goodies!!!


    // Awake is called when the script instance is being loaded
    public void Awake()
    {
        if (Instance == null)
        {
            //sets the static reference to "this" instance of the script.
            Instance = this;
        }
    }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerGrenadeShrap").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
     Trail        = Resources.Load("ShortTrail") as GameObject;
 }
Beispiel #10
0
 // Use this for initialization
 void Start()
 {
     //set stuff to be changed
     Body  = body.GetComponent <SpriteRenderer> ();
     Head  = head.GetComponent <SpriteRenderer> ();
     full  = GetComponent <Transform> ();
     Laser = GameObject.Find("PoolLasers").GetComponent <ObjectPoolScript>();
 }
Beispiel #11
0
 // Start is called before the first frame update
 void Start()
 {
     animator = gameObject.GetComponent <Animator>();
     pool     = gameObject.GetComponent <ObjectPoolScript>();
     renderer = gameObject.GetComponent <SpriteRenderer>();
     Player   = GameObject.FindWithTag("Player");
     pc       = Player?.GetComponent <PlayerController>();
     pes      = GetComponent <PotionEffectsScript>();
 }
Beispiel #12
0
    public void Shoot(GameObject go)
    {
        //Instantiate(gameSettings.ShootingEffect, muzzleMain.transform.position, muzzleMain.rotation);
        ObjectPoolScript.Spawn(gameSettings.ShootingEffect, muzzleMain.transform.position, muzzleMain.rotation);
        //GameObject missleGo = Instantiate(gameSettings.Bullet, muzzleMain.transform.position, muzzleMain.rotation);
        GameObject missleGo   = ObjectPoolScript.Spawn(gameSettings.Bullet, muzzleMain.transform.position, muzzleMain.rotation);
        Projectile projectile = missleGo.GetComponent <Projectile>();

        projectile.target = currentTarget.transform;
    }
Beispiel #13
0
	// Use this for initialization
	void Start () {
		//poolE = GameObject.Find ("EnemyPool").GetComponent<ObjectPoolScript> ();
		poolS = GameObject.Find ("SpawnerPool").GetComponent<ObjectPoolScript> ();
		poolc = GameObject.Find("CratePool").GetComponent<ObjectPoolScript> ();
		nextLevel ();
		reward = Instantiate (reward, Vector3.zero, Quaternion.identity) as GameObject;
		reward.GetComponent<Reward> ().ply (pl);
		reward.SetActive (false);
		Random.seed = System.DateTime.Now.Millisecond;

	}
 // Use this for initialization
 void Start()
 {
     //poolE = GameObject.Find ("EnemyPool").GetComponent<ObjectPoolScript> ();
     poolS = GameObject.Find("SpawnerPool").GetComponent <ObjectPoolScript> ();
     poolc = GameObject.Find("CratePool").GetComponent <ObjectPoolScript> ();
     nextLevel();
     reward = Instantiate(reward, Vector3.zero, Quaternion.identity) as GameObject;
     reward.GetComponent <Reward> ().ply(pl);
     reward.SetActive(false);
     Random.seed = System.DateTime.Now.Millisecond;
 }
 public void SetUpButton(ItemClass passedItem, ItemListManager passedListManager)
 {
     listManager      = passedListManager;
     item             = passedItem;
     nameText.text    = item.itemType;
     LvlText.text     = "Lvl: " + item.level.ToString();
     QualityText.text = item.QualityIntToString();
     GetComponent <LayoutElement>().preferredHeight = transform.parent.GetComponent <RectTransform>().rect.width / 4;
     iconSprite       = listManager.SetIconSprite(item.itemType);
     iconImage.sprite = iconSprite;
     itemEquipPool    = passedListManager.itemEquipPool;
 }
Beispiel #16
0
 void Awake()
 {
     animator              = GetComponent <Animator>();
     timeUtils             = GetComponent <TimeUtils>();
     flashRed              = GetComponent <FlashUsingMaterial>();
     colliderWhenIntact    = GetComponent <Collider2D>();
     colliderWhenDestroyed = GetComponent <EdgeCollider2D>();
     collectible           = GetComponentInChildren <CollectibleDef>(true);
     healthManager         = GetComponent <HealthManager>();
     berserkerPool         = GetComponentInChildren <ObjectPoolScript>();
     berserkersOnTheRoof   = new Berserker[3];
 }
Beispiel #17
0
 // Use this for initialization
 void Start()
 {
     PCS = GetComponent <PlayerControlScript> ();
     SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OP  = GameObject.Find("ObjectPoolerIntercept").GetComponent <ObjectPoolScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 50;
     CanShoot          = true;
     projectile        = Resources.Load("InterCeptorPrefab") as GameObject;
 }
Beispiel #18
0
	void Awake () {
        DontDestroyOnLoad(this);
	    audioSourcePool = gameObject.AddComponent<ObjectPoolScript>();
        if (soundPrefab != null) {
            audioSourcePool.pooledObject = soundPrefab;
        } else {
            soundPrefab = Resources.Load<GameObject>("Sound");
            audioSourcePool.pooledObject = soundPrefab;
        }

        audioSourcePool.pooledAmount = 10;
        audioSourcePool.willGrow = true;
	}
    /// <summary>
    /// This PoolReferenceSetup Method creates our references to the ball pools(all of them), and the Bomb Pool(only one of those).
    /// </summary>
    public void PoolReferenceSetup()
    {
        //find the GameObject Tagged "Ball Pool".
        ballPoolsGameObject = GameObject.FindGameObjectWithTag(Tags.BallPools);
        //then fill the ballPoolScripts array with the ObjectPoolScripts (all the children of the ballPoolsGameObject).
        ballPoolScripts = ballPoolsGameObject.GetComponentsInChildren <ObjectPoolScript>();

        //find the GameObject Tagged "OtherPools".
        bombPoolGameObject = GameObject.FindGameObjectWithTag(Tags.OtherPools);

        //then fill the bombPoolScripts array with the ObjectPoolScripts (the child of the bombPoolsGameObject).
        bombPoolScript = bombPoolGameObject.GetComponentInChildren <ObjectPoolScript>();
    }
Beispiel #20
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerTripMine").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 25;
     CanShoot          = true;
 }
Beispiel #21
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerFireArrow").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(3);
     AS.SetReloadTime(1.5f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 15;
     CanShoot          = true;
 }
Beispiel #22
0
    void Awake()
    {
        groundCheck   = transform.Find("groundCheck");
        wallCheck     = transform.Find("wallCheck");
        ceilingCheck  = transform.Find("ceilingCheck");
        ceilingCheck2 = transform.Find("ceilingCheck2");
        sprRenderer   = GetComponent <SpriteRenderer>();

        rb               = GetComponent <Rigidbody2D>();
        jumpSound        = GetComponent <AudioSource>();
        anim             = GetComponent <Animator>();
        objectPoolScript = GetComponent <ObjectPoolScript>();
        photonview       = GetComponent <PhotonView>();
    }
Beispiel #23
0
    void Awake()
    {
        groundCheck = transform.Find("groundCheck");
        wallCheck = transform.Find("wallCheck");
        ceilingCheck = transform.Find("ceilingCheck");
        ceilingCheck2 = transform.Find("ceilingCheck2");
        sprRenderer = GetComponent<SpriteRenderer>();

        rb = GetComponent<Rigidbody2D>();
        jumpSound = GetComponent<AudioSource>();
        anim = GetComponent<Animator>();
        objectPoolScript = GetComponent<ObjectPoolScript>();
        photonview = GetComponent<PhotonView>();

    }
Beispiel #24
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerBoomerang").GetComponent <ObjectPoolScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(1);
     AS.SetReloadTime(2f);
     PCS.SetPrimaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 35;
     CanShoot          = true;
     projectile        = Resources.Load("BoomerangProjectilePrefab") as GameObject;
     Trail             = Resources.Load("ShortTrail") as GameObject;
 }
Beispiel #25
0
    // Use this for initialization
    void Start()
    {
        ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
        SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
        PCS = GetComponent <PlayerControlScript> ();
        AS  = GetComponent <AmmoScript>();
        AS.SetSecondaryMagazineSize(1);
        PCS.SetSecondaryWeapon(ShootOutline);
        PCS.SetSecondaryWeaponRelease(Shoot);
        CanShoot   = true;
        projectile = Resources.Load("WallRevisedProjectileoutlinePrefab") as GameObject;
        OPWall     = GameObject.Find("ObjectPoolerWall").GetComponent <ObjectPoolScript> ();
        POutline   = Instantiate(projectile, Vector3.zero, Quaternion.identity) as GameObject;
        Color CtoChange = ES.GetColor(PCS.GetPlayerNum());

        CtoChange.a = .75f;
        POutline.GetComponent <SpriteRenderer> ().color = CtoChange;
        POutline.SetActive(false);
    }
Beispiel #26
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerGrenade").GetComponent <ObjectPoolScript> ();
     OPTrail      = GameObject.Find("ObjectPoolerTrailS").GetComponent <ObjectPoolScript> ();
     AS           = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Cook);
     PCS.SetSecondaryWeaponRelease(Shoot);
     ShotTimer           = 0;
     CookTime            = 0;
     ShootFireCooldown   = 50;
     CanShoot            = true;
     projectile          = Resources.Load("GrenadePrefab") as GameObject;
     Trail               = Resources.Load("ShortTrail") as GameObject;
     GrenadeDetonateTime = projectile.GetComponent <ProjectileScript> ().SelfDestruct;
 }
 /// <summary>
 /// Create a new object pool of the objects you wish to pool
 /// </summary>
 /// <param name="objToPool">The object you wish to pool.  The name property of the object MUST be unique.</param>
 /// <param name="initialPoolSize">Number of objects you wish to instantiate initially for the pool.</param>
 /// <param name="maxPoolSize">Maximum number of objects allowed to exist in this pool.</param>
 /// <param name="shouldShrink">Should this pool shrink back down to the initial size when it receives a shrink event.</param>
 /// <returns></returns>
 public bool CreatePool(GameObject objToPool, int initialPoolSize, int maxPoolSize)
 {
     //Check to see if the pool already exists.
     if (ObjectPoolManagerScript.Instance.objectPools.ContainsKey(objToPool.name))
     {
         //let the caller know it already exists, just use the pool out there.
         return(false);
     }
     else
     {
         //create a new pool using the properties
         ObjectPoolScript nPool = new ObjectPoolScript(objToPool, initialPoolSize, maxPoolSize);
         //Add the pool to the dictionary of pools to manage
         //using the object name as the key and the pool as the value.
         ObjectPoolManagerScript.Instance.objectPools.Add(objToPool.name, nPool);
         //We created a new pool!
         return(true);
     }
 }
    void Awake()
    {
        if (ValueDeliverScript.isBgSound == false)
        {
            GetComponent <AudioSource>().volume = 0f;
        }
        else
        {
            GetComponent <AudioSource>().volume = 1f;
        }

        //GetComponent<AudioSource>().volume = ValueDeliverScript.fxSound*3f;
        //Debug.Log("GetComponent<AudioSource>().volume" + GetComponent<AudioSource>().volume);
        objPool            = GameObject.Find("GameManager").GetComponent <ObjectPoolScript>();
        characterMessageUI = GameObject.Find("CharacterMessageUI");

        GetComponent <AudioSource>().volume = ValueDeliverScript.characterSound;

        soundSix = GameObject.Find("GameManager").GetComponent <ObjectPoolScript>().countDown6Ai;
    }
Beispiel #29
0
 // Use this for initialization
 void Start()
 {
     ES           = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS          = GetComponent <PlayerControlScript> ();
     SPS          = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     OPProjectile = GameObject.Find("ObjectPoolerLazer").GetComponent <ObjectPoolScript> ();
     particlesOBJ = Resources.Load("ChargeParticleHolder") as GameObject;
     AS           = GetComponent <AmmoScript>();
     AS.SetPrimaryMagazineSize(6);
     AS.SetReloadTime(3f);
     PCS.SetPrimaryWeapon(Charge);
     PCS.SetPrimaryWeaponRelease(Shoot);
     ShotTimer                  = 0;
     chargeLevel                = 1;
     ShootFireCooldown          = 7;
     CanShoot                   = true;
     particlesOBJ               = Instantiate(particlesOBJ, transform.position, transform.rotation) as GameObject;
     particlesSystem            = particlesOBJ.GetComponentInChildren <ParticleSystem> ();
     particlesSystem.startColor = ES.GetColor(PCS.GetPlayerNum());
     particlesOBJ.SetActive(false);
 }
Beispiel #30
0
    private void Awake()
    {
        current = this;

        pooledObjects = new List<GameObject> ();
        int j = -1;
        for (int i=0; i< pooledAmount; i++)
        {
            if (j == objectsBeingPooled.GetLength(0) - 1)
            {
                j = 0;
            }
            else
            {
                j +=1;
            }

            GameObject obj = (GameObject)Instantiate(objectsBeingPooled[j]);
            obj.SetActive(false);
            pooledObjects.Add(obj);
        }
    }
Beispiel #31
0
    /// <summary>
    /// This Method Grabs us a Bomb or a PowerUp from the pool puts it in position and activates it. This method is
    /// called from the "LoadAndFireOtherObject()"
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public GameObject RetrieveOtherFromPool(int type)
    {
        //create a ObjectPoolScript var and name it tempPool and then assign it the element at position "type" in the array.
        ObjectPoolScript tempPool = bombAndPowerUpPoolScripts[type];
        //new gameObject "obj" gets a pooled object from tempPool reference using GetPooledObject.
        GameObject obj = tempPool.GetPooledObject();

        //if the obj equals null...
        if (obj == null)
        {
            //return null
            return(null);
        }
        //the obj's position gets our position
        obj.transform.position = transform.position;
        //the obj's rotation gets our rotation
        obj.transform.rotation = transform.rotation;
        //the obj gets set active
        obj.SetActive(true);
        //return obj...
        return(obj);
    }
    public void SetUpButton(ItemClass passedItem, ItemListManager passedListManager)
    {
        listManager = passedListManager;
        item        = passedItem;
        ItemClass.SetItemValues(passedItem);
        nameText.text    = passedItem.TypeName;
        LvlText.text     = "Lvl: " + passedItem.Level.ToString();
        QualityText.text = passedItem.GetQualityStr();
        GetComponent <LayoutElement>().preferredHeight = transform.parent.GetComponent <RectTransform>().rect.width / 4;
        iconImage.sprite = passedItem.Icon;
        itemEquipPool    = passedListManager.itemEquipPool;
        switch (item.qualityInt)
        {
        case 0: QualityColor.color = Color.gray; break;

        case 1: QualityColor.color = Color.white; break;

        case 2: QualityColor.color = new Color(0.5f, 0.5f, 1f, 1f); break;

        case 3: QualityColor.color = Color.yellow; break;

        default: break;
        }

        float         iconSize = listManager.iconSize;
        RectTransform rect     = iconImage.GetComponent <RectTransform>();

        if (passedItem.Size.y >= passedItem.Size.x)
        {
            rect.sizeDelta = new Vector2(iconSize / IntVector2.Slope(passedItem.Size), iconSize);
        }
        else
        {
            rect.sizeDelta = new Vector2(iconSize, iconSize * IntVector2.Slope(passedItem.Size));
        }
    }
	// Use this for initialization
	void Start () {
		pool = GameObject.Find ("EnemyPool").GetComponent<ObjectPoolScript> ();
		gameObject.SetActive (true);
	}
Beispiel #34
0
    public List <GameObject> pooledObjects;     //the list that will hold all of our goodies!!!


    // Awake is called when the script instance is being loaded
    public void Awake()
    {
        //sets the static reference to "this" instance of the script.
        current = this;
    }
 void Awake()
 {
     current = this;
 }
 void OnEnable()
 {
     instance = this;
 }
Beispiel #37
0
	void Awake(){

		sprRend = GetComponent<SpriteRenderer>(); 
		objectPoolScript = GetComponent<ObjectPoolScript> ();
	}
Beispiel #38
0
	void Awake() {

		current = this;
	}