コード例 #1
0
ファイル: PlanetUI.cs プロジェクト: UESTC-Programmers/OrbitII
        IEnumerator DropControllCenter(Transform startPos, Planet thatPlanet)
        {
            float   minDis       = float.MaxValue;
            Vector3 targetPos    = startPos.position;
            int     nearestIndex = 0;

            for (int i = 0; i < thatPlanet.AreaCount; i++)
            {
                Vector3 landPos = thatPlanet.GetIndexPosition(i);
                float   dis     = Vector3.Distance(landPos, startPos.position);
                if (dis < minDis)
                {
                    minDis       = dis;
                    targetPos    = landPos;
                    nearestIndex = i;
                }
            }
            Debug.Log("nearestIndex" + nearestIndex);
            while (Vector3.Distance(startPos.position, targetPos) > 0.1f)
            {
                startPos.position = Vector3.Lerp(startPos.position, targetPos, centerFlySpeed);
                yield return(null);
            }
            thatPlanet.CreateColony();
            BuildingBase building = Instantiate <GameObject>(ControlCenter.GetBuildingPrefab(BuildingType.CONTROL_CENTER)).GetComponent <BuildingBase>();

            Build(building, nearestIndex, thatPlanet);
            EventManager.Instance.PostEvent(GameEvent.COLONY_SET_UP, thatPlanet);
            Destroy(startPos.gameObject);
        }
コード例 #2
0
ファイル: ControlCenter.cs プロジェクト: GuochuSang/OrbitII
        public override T Create <T>(ID id)
        {
            Debug.Log("控制中心从存档创建!!");
            GameObject    go = GameObject.Instantiate(BuildingBase.GetBuildingPrefab(BuildingType.CONTROL_CENTER));
            ControlCenter cc = go.GetComponent <ControlCenter>();

            id.Init();
            cc.id = id;
            SaveManager.Instance.Load(cc, id);
            return((T)(System.Object)cc);
        }
コード例 #3
0
 void ExitControlCenter()
 {
     currentControlCenter = null;
     EventManager.Instance.PostEvent(GameEvent.EXIT_BUILDING_AREA, this);
     Debug.Log("离开了控制中心");
 }
コード例 #4
0
 void EnterControlCenter(ControlCenter center)
 {
     currentControlCenter = center;
     EventManager.Instance.PostEvent(GameEvent.ENTER_BUILDING_AREA, this, center);
     Debug.Log("靠近了控制中心");
 }