Пример #1
0
        private void CreateProductedUnit()
        {
            RTSUnit unit = (RTSUnit)Entities.Instance.Create(productUnitType, Map.Instance);

            RTSCharacter character = unit as RTSCharacter;

            if (character == null)
            {
                Log.Fatal("RTSBuilding: CreateProductedUnit: character == null");
            }

            GridBasedNavigationSystem navigationSystem = GridBasedNavigationSystem.Instances[0];
            Vec2 p = navigationSystem.GetNearestFreePosition(Position.ToVec2(), character.Type.Radius * 2);

            unit.Position = new Vec3(p.X, p.Y, navigationSystem.GetMotionMapHeight(p) + character.Type.Height * .5f);

            if (Intellect != null)
            {
                unit.InitialFaction = Intellect.Faction;
            }

            unit.PostCreate();
        }