Пример #1
0
        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
        public void LookBuilding(int index)
        {
            var pos = currentPlanet.GetIndexPosition(index);
            var rot = currentPlanet.GetIndexRotation(index);

            CameraController.Instance.SetPosition(pos);
            CameraController.Instance.SetRotation(rot);
            currentBuildingName = currentPlanet.colony.GetBuildingAtIndex(index, out currentBuilding);

            EventManager.Instance.PostEvent(GameEvent.LOOK_BUILDING, currentBuilding, currentBuildingName);
        }