예제 #1
0
        public void RecyclePlane(PlaneAttribute planeAttribute)
        {
            string     modelKey = planeAttribute.Model;
            GameObject planeObj = planeAttribute.gameObject;

            planeObj.tag = "Untagged";

            List <Component> comList = new List <Component>();

            foreach (var component in planeObj.GetComponents <Component>())
            {
                comList.Add(component);
            }
            foreach (Component item in comList)
            {
                Destroy(item);
            }

            if (mInactivePlaneDict.ContainsKey(modelKey))
            {
                mInactivePlaneDict[modelKey].Add(planeObj);
            }
            else
            {
                mInactivePlaneDict.Add(modelKey, new List <GameObject> {
                    planeObj
                });
            }
        }
예제 #2
0
        public void InitPlayer()
        {
            mPlayerPlane    = PlanePool.Instance.AddPlaneByModel("Player", PlaneType.Player);
            mPlayerPlane.Id = ReturnIndex();
            mFlightPlaneDict.Add(mPlayerPlane.Id, mPlayerPlane);

            UIMgr.OpenPanel <UIHUD>();
        }
예제 #3
0
        public void ProducteEnemy()
        {
            int enemyIndex = ReturnIndex();

            PlaneAttribute enemyPlane = PlanePool.Instance.AddPlaneByModel("J_11", PlaneType.Enemy);

            enemyPlane.gameObject.AddComponent <AISys>().Load(100f, mPlayerPlane.transform);
            enemyPlane.Id = enemyIndex;
            mFlightPlaneDict.Add(enemyPlane.Id, enemyPlane);
            enemyPlane.Show();
        }
예제 #4
0
        public PlaneAttribute AddPlaneByModel(string model, PlaneType planeType = PlaneType.Enemy)
        {
            if (!ModelResMgr.Instance.ActivePlaneDict.ContainsKey(model))
            {
                return(null);
            }

            GameObject PlaneObj = null;

            if (mInactivePlaneDict.ContainsKey(model))
            {
                PlaneObj = mInactivePlaneDict[model][0];
                mInactivePlaneDict[model].RemoveAt(0);

                if (mInactivePlaneDict[model].Count == 0 || mInactivePlaneDict[model] == null)
                {
                    mInactivePlaneDict.Remove(model);
                }
            }
            else
            {
                PlaneObj = Instantiate(mResLoader.LoadSync <GameObject>(Planepre.BundleName, model)) as GameObject;
            }

            PlaneAttribute planeAttribute = PlaneObj.AddComponent <PlaneAttribute>();

            planeAttribute.hpElement               = PlaneObj.AddComponent <HPElement>();
            planeAttribute.CtrlType                = planeType;
            planeAttribute.Model                   = model;
            planeAttribute.gameObject.tag          = planeType.ToString();
            planeAttribute.transform.localPosition = new Vector3(-456.4f, 146.9f, 363.2f);

            switch (planeType)
            {
            case PlaneType.Player:
                PlaneObj.AddComponent <Player>();
                break;

            case PlaneType.Friendly:
                PlaneObj.AddComponent <Friendly>();
                break;

            case PlaneType.Enemy:
                PlaneObj.AddComponent <Enemy>();
                break;

            default:
                break;
            }

            return(planeAttribute);
        }
예제 #5
0
 void Start()
 {
     mPlaneAttribute = gameObject.GetComponent <PlaneAttribute>();
 }