Inheritance: AKMapObject
Ejemplo n.º 1
0
        public void ApplyChangeMapInformation(ChangeMapInformation information,
            SpawnPoint spawnPoint)
        {
            if (spawnPoint == null)
                return;

            Position = spawnPoint.Position + information.position * spawnPoint.Rotation;
            ((PlayerIntellect)Intellect).LookDirection =
                information.lookDirection * spawnPoint.Rotation;
            MainBody.LinearVelocity = information.velocity * spawnPoint.Rotation;

            OldPosition = Position;
            OldRotation = Rotation;

            weapons = information.weapons;
            SetActiveWeapon(information.activeWeaponIndex);

            Life = information.life;
        }
Ejemplo n.º 2
0
        Unit ServerOrSingle_CreatePlayerUnit( PlayerManager.ServerOrSingle_Player player,
			SpawnPoint spawnPoint )
        {
            string unitTypeName;
            if( !player.Bot )
                unitTypeName = "Rabbit";
            else
                unitTypeName = player.Name;

            Unit unit = (Unit)Entities.Instance.Create( unitTypeName, Map.Instance );

            Vec3 posOffset = new Vec3( 0, 0, 1.5f );//!!!!temp
            unit.Position = spawnPoint.Position + posOffset;
            unit.Rotation = spawnPoint.Rotation;
            unit.PostCreate();

            if( player.Intellect != null )
            {
                player.Intellect.ControlledObject = unit;
                unit.SetIntellect( player.Intellect, false );
            }

            return unit;
        }
Ejemplo n.º 3
0
        Unit ServerOrSingle_CreatePlayerUnit( PlayerManager.ServerOrSingle_Player player,
			SpawnPoint spawnPoint )
        {
            SpawnPoint sp = spawnPoint;
            string unitTypeName;
            if (!player.Bot)
            {
                //unitTypeName = "Human";
                //new stuff
                ICollection<Entity> icol = Entities.Instance.EntitiesCollection;
                IEnumerator<Entity> num = icol.GetEnumerator();
                num.Reset();
                num.MoveNext();
                int human_ctr = 0;
                int statue_ctr = 0;
                //Console.WriteLine(icol.Count);
                for (int i = 0; i < icol.Count; i++)
                {
                    Entity mo = num.Current;
                    Console.WriteLine(mo.Type.ToString());

                    if (mo.Name.ToString().Contains("Human"))
                    {
                        human_ctr++;
                    }
                    if (mo.Name.ToString().Contains("Statue"))
                    {
                        statue_ctr++;
                    }
                    num.MoveNext();
                }
                if (human_ctr <= statue_ctr)
                {
                    unitTypeName = "Human";
                    sp = Entities.Instance.GetByName("human_spawn") as SpawnPoint;
                }
                else
                {
                    unitTypeName = "Statue";
                    sp = Entities.Instance.GetByName("statue_spawn") as SpawnPoint;
                }
                //end
            }
            else
                unitTypeName = player.Name;

            Unit unit = (Unit)Entities.Instance.Create( unitTypeName, Map.Instance );

            Vec3 posOffset = new Vec3( 0, 0, 1.5f );//!!!!temp
            unit.Position = sp.Position + posOffset;
            unit.Rotation = sp.Rotation;
            unit.PostCreate();

            if( player.Intellect != null )
            {
                player.Intellect.ControlledObject = unit;
                unit.SetIntellect( player.Intellect, false );
            }

            return unit;
        }
Ejemplo n.º 4
0
        internal void DoActionsAfterMapCreated()
        {
            if (EntitySystemWorld.Instance.IsSingle())
            {
                if (GameMap.Instance.GameType == GameMap.GameTypes.Action ||
                    GameMap.Instance.GameType == GameMap.GameTypes.TPSArcade ||
                    GameMap.Instance.GameType == GameMap.GameTypes.TurretDemo)
                {
                    string playerName = "__SinglePlayer__";

                    //create Player
                    PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance.
                                                                 ServerOrSingle_GetPlayer(playerName);
                    if (player == null)
                    {
                        player = PlayerManager.Instance.Single_AddSinglePlayer(playerName);
                    }

                    //create PlayerIntellect
                    PlayerIntellect intellect = null;
                    {
                        //find already created PlayerIntellect
                        foreach (Entity entity in World.Instance.Children)
                        {
                            intellect = entity as PlayerIntellect;
                            if (intellect != null)
                            {
                                break;
                            }
                        }

                        if (intellect == null)
                        {
                            intellect = (PlayerIntellect)Entities.Instance.Create("PlayerIntellect",
                                                                                  World.Instance);
                            intellect.PostCreate();

                            player.Intellect = intellect;
                        }

                        //set instance
                        if (PlayerIntellect.Instance == null)
                        {
                            PlayerIntellect.SetInstance(intellect);
                        }
                    }

                    //create unit
                    if (intellect.ControlledObject == null)
                    {
                        SpawnPoint spawnPoint = null;
                        if (shouldChangeMapSpawnPointName != null)
                        {
                            spawnPoint = Entities.Instance.GetByName(shouldChangeMapSpawnPointName)
                                         as SpawnPoint;
                            if (spawnPoint == null)
                            {
                                Log.Error("GameWorld: SpawnPoint with name \"{0}\" is not defined.",
                                          shouldChangeMapSpawnPointName);
                            }
                        }

                        Unit unit;
                        if (spawnPoint != null)
                        {
                            unit = ServerOrSingle_CreatePlayerUnit(player, spawnPoint);
                        }
                        else
                        {
                            unit = ServerOrSingle_CreatePlayerUnit(player);
                        }

                        if (shouldChangeMapPlayerCharacterInformation != null)
                        {
                            PlayerCharacter playerCharacter = (PlayerCharacter)unit;
                            playerCharacter.ApplyChangeMapInformation(
                                shouldChangeMapPlayerCharacterInformation, spawnPoint);
                        }
                        else
                        {
                            if (unit != null)
                            {
                                intellect.LookDirection = SphereDir.FromVector(
                                    unit.Rotation.GetForward());
                            }
                        }
                    }
                }
            }

            shouldChangeMapName                       = null;
            shouldChangeMapSpawnPointName             = null;
            shouldChangeMapPlayerCharacterInformation = null;
        }