Esempio n. 1
0
    public void BtnSpawnFromPool(int repeat, string tag)
    {
        GameObject    ObjToSpawn;
        BtnController btnControl;

        if (!poolDictionary.ContainsKey(tag))
        {
            Debug.LogWarning("Pool whit tag" + tag + "doesn't exist ");
            return;
        }

        for (int i = 0; i <= repeat; i++)
        {
            ObjToSpawn = poolDictionary[tag].Dequeue();                           //Get a object of the pool
            ObjToSpawn.SetActive(true);                                           //Active the object
            ObjToSpawn.transform.position = new Vector2(290.0f, positions[i][1]); //Set a position
            btnControl              = ObjToSpawn.GetComponent <BtnController>();  //I don't know what i do here
            btnControl.TextToShow   = optionInfo[i];                              //Set text to the variable TextToShow of BtnController (script)
            btnControl.CharRep      = ChRep[i];                                   //Send character's name to reply to script BtnController
            btnControl.Conversation = Conversation[i];                            //Send de number conversation  to script BtnController
            btnControl.NextNode     = Node[i];                                    //Send the node of conversation to script BtnController
            poolDictionary[tag].Enqueue(ObjToSpawn);                              //give back the object to the pool
        }
        #region ClearLists
        positions.Clear();
        Conversation.Clear();
        Node.Clear();
        ChRep.Clear();
        optionInfo.Clear();
        #endregion
    }
Esempio n. 2
0
 private void SpawnEnemy(ObjToSpawn obj)
 {
     if (obj == ObjToSpawn.enemy)
     {
         var go = Instantiate(enemy, transform.position, Quaternion.identity);
         go.entitySpawner = this;
     }
     else
     {
         var go = Instantiate(axe, new Vector2(-13.4f, -2.5f), Quaternion.identity);
         go.GetComponent <HingeJoint2D>().connectedBody = bodyForJoint;
         throwMechanic.GetInfoAboutObj(go);
         dragIndicator.ObjectToThrow = go.GetComponent <Rigidbody2D>();
     }
 }