コード例 #1
0
    public Cannon CreateCannon(CannonTypes type, Vector3 position)
    {
        //Simply create a cannon and return it. Let whoever gets it deal with it as they wish.
        //Cannon c = Instantiate(CannonCatalogue[(int)type],position,Quaternion.identity) as Cannon;

        Cannon c = CannonPool[(int)type].GetItem();

        //If the cannon didnt exist then we create it.
        if (c == null)
        {
            c = Instantiate(CannonCatalogue[(int)type], position, Quaternion.identity) as Cannon;

            //Set the type for the cannon.
            c.CannonTypeInfo = type;

            //Make a child?
            c.transform.parent = transform;

            //Add to the pool list.
            CannonPool[(int)type].AddItem(c);

            //We should return now should we?
            c = CannonPool[(int)type].GetItem();
        }

        //Now we set the position
        c.transform.position = position;
        c.transform.rotation = Quaternion.identity;

        //Activet the object.
        c.gameObject.SetActive(true);

        //Set not dirty
        c.SetDirty(false);

        //Add to the active list
        ActiveCannonList.Add(c);

        //Return the temp storage incase we need to make our own modificaions
        return(c);
    }
コード例 #2
0
 public string GetCannonIconName(CannonTypes type)
 {
     return(CannonCatalogue[(int)type].CannonTextureName);
 }