本文整理汇总了C#中Sandbox.Game.World.MyPlayer类的典型用法代码示例。如果您正苦于以下问题:C# MyPlayer类的具体用法?C# MyPlayer怎么用?C# MyPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MyPlayer类属于Sandbox.Game.World命名空间,在下文中一共展示了MyPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBot
public IMyBot CreateBot(MyPlayer player, MyObjectBuilder_Bot botBuilder, MyBotDefinition botDefinition)
{
var output = new MySandboxBot(player, botDefinition);
if (botBuilder != null)
output.Init(botBuilder);
return output;
}
示例2: Update
public bool Update(MyPlayer player, MyEntity entity) //returns if lost
{
//MySessionComponentMission.Static.TryCreateFromDefault(Id);
//if (IsLocal(player.Id))
// UpdateLocal(player.Id);
if (!Sync.IsServer)
return false;
MyMissionTriggers mtrig;
if (!MissionTriggers.TryGetValue(player.Id, out mtrig))
{
//Debug.Assert(false,"Bad ID for update in missionTriggers");
mtrig = TryCreateFromDefault(player.Id, false);
}
mtrig.UpdateWin(player, entity);
if (!mtrig.Won)
mtrig.UpdateLose(player, entity);
else
{
m_someoneWon = true;
MyAnalyticsHelper.ReportTutorialEnd();
}
return mtrig.Lost;
}
示例3: PlayerLost
public static void PlayerLost(MyPlayer.PlayerId id, int triggerIndex)
{
MySessionComponentMissionTriggers.Static.SetLost(id, triggerIndex);
if (!Sync.MultiplayerActive || !MySession.Static.IsScenario)
return;
LostMsg msg = new LostMsg();
msg.index = triggerIndex;
msg.playerId = id;
Sync.Layer.SendMessageToAll(ref msg, MyTransportMessageEnum.Success);
}
示例4: SendControlPilotMsg
public void SendControlPilotMsg(MyPlayer player)
{
var msg = new ControlPilotMsg();
msg.EntityId = Entity.Entity.EntityId;
msg.SteamId = player.Id.SteamId;
msg.SerialId = player.Id.SerialId;
MySession.Static.SyncLayer.SendMessageToAllAndSelf(ref msg);
}
示例5: Update
/*public bool Update(MyFaction faction, MyCharacter me)
{
bool res = false;
if (faction != null)
res = Update(faction.FactionId, me);
else
res = Update(me.EntityId, me);
return res;
}*/
/*public bool Update()
{
return false;
}*/
public bool Update(MyPlayer.PlayerId Id, MyCharacter me)
{
MyMissionTriggers mtrig;
if (!MissionTriggers.TryGetValue(Id, out mtrig))
{
//Debug.Assert(false,"Bad ID for update in missionTriggers");
return false;
}
mtrig.UpdateWin(me);
mtrig.UpdateLose(me);//!!
return false;
}
示例6: MySandboxBot
public MySandboxBot(MyPlayer botPlayer, MyBotDefinition botDefinition)
{
m_definition = botDefinition as MyAgentDefinition;
m_player = botPlayer;
m_navigation = new MyBotNavigation();
m_respawnRequestSent = false;
m_actionCollection = null;
m_botMemory = new MyBotMemory(this);
m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged;
m_navigation.ChangeEntity(m_player.Controller.ControlledEntity);
}
示例7: MyHumanoidBot
public MyHumanoidBot(MyPlayer player, MyBotDefinition botDefinition)
: base(player, botDefinition)
{
Debug.Assert(botDefinition is MyHumanoidBotDefinition, "Provided bot definition is not of humanoid type");
if (m_player.Controller.ControlledEntity is MyCharacter) // when loaded player already controls entity
{
var character = m_player.Controller.ControlledEntity as MyCharacter;
if (character.CurrentWeapon == null && StartingWeaponId.SubtypeId != MyStringHash.NullOrEmpty)
{
AddItems(character);
}
}
Sandbox.Game.Gui.MyCestmirDebugInputComponent.PlacedAction += DebugGoto;
}
示例8: TryCreateFromDefault
public void TryCreateFromDefault(MyPlayer.PlayerId newId, bool overwrite)
{
if (overwrite)
MissionTriggers.Remove(newId);
else
if (MissionTriggers.ContainsKey(newId))
return;//already exists, thats ok for us
MyMissionTriggers mtrig = new MyMissionTriggers();
MissionTriggers.Add(newId, mtrig);
MyMissionTriggers source;
MissionTriggers.TryGetValue(new MyPlayer.PlayerId(0,0), out source);
if (source == null)
//older save which does not have defaults set
return;
mtrig.CopyTriggersFrom(source);
}
示例9: Update
public bool Update(MyPlayer.PlayerId Id, MyEntity entity) //returns if lost
{
//MySessionComponentMission.Static.TryCreateFromDefault(Id);
if (IsLocal(Id))
UpdateLocal(Id);
if (!Sync.IsServer)
return false;
MyMissionTriggers mtrig;
if (!MissionTriggers.TryGetValue(Id, out mtrig))
{
//Debug.Assert(false,"Bad ID for update in missionTriggers");
mtrig=TryCreateFromDefault(Id, false);
}
mtrig.UpdateWin(Id, entity);
if (!mtrig.Won)
mtrig.UpdateLose(Id, entity);
else
m_someoneWon = true;
return mtrig.Lost;
}
示例10: ResetPlayerIdentity
public void ResetPlayerIdentity(MyPlayer player)
{
if (player.Identity != null)
{
if (MySession.Static.Settings.PermanentDeath.Value)
{
if (!player.Identity.IsDead)
Sync.Players.KillPlayer(player);
var faction = MySession.Static.Factions.TryGetPlayerFaction(player.Identity.IdentityId);
if (faction != null)
MyFactionCollection.KickMember(faction.FactionId, player.Identity.IdentityId);
//Clear chat history
if (MySession.Static.ChatSystem != null)
{
MySession.Static.ChatSystem.ClearChatHistoryForPlayer(player.Identity);
}
var identity = Sync.Players.CreateNewIdentity(player.DisplayName);
player.Identity = identity;
}
}
}
示例11: SetupCharacterDefault
public abstract void SetupCharacterDefault(MyPlayer player, MyWorldGenerator.Args args);
示例12: CreateNewIdentity
public abstract MyIdentity CreateNewIdentity(string identityName, MyPlayer.PlayerId playerId, string modelName);
示例13: SendNewGlobalMessage
public void SendNewGlobalMessage(MyPlayer.PlayerId senderId, string text)
{
MyMultiplayer.RaiseEvent(this, x => x.OnGlobalMessageRequest, senderId.SteamId, text);
}
示例14: SetPlayer
public void SetPlayer(MyPlayer player, bool update = true)
{
m_controlInfo.Value = player.Id;
if (Sync.IsServer && update)
{
MyPlayerCollection.ChangePlayerCharacter(player, this, this);
}
}
示例15: CreateBot
public IMyBot CreateBot(MyPlayer player, MyObjectBuilder_Bot botBuilder, MyBotDefinition botDefinition)
{
Debug.Assert(m_botDataByBehaviorType.ContainsKey(botDefinition.BehaviorType), "Undefined behavior type. Bot is not going to be created");
if (!m_botDataByBehaviorType.ContainsKey(botDefinition.BehaviorType))
return null;
Debug.Assert(m_botTypeByDefinitionType.ContainsKey(botDefinition.TypeDefinitionId.TypeId), "Type not found. Bot is not going to be created!");
if (!m_botTypeByDefinitionType.ContainsKey(botDefinition.TypeDefinitionId.TypeId))
return null;
var botData = m_botDataByBehaviorType[botDefinition.BehaviorType];
var behaviorTypeData = m_botTypeByDefinitionType[botDefinition.TypeDefinitionId.TypeId];
IMyBot output = CreateBot(behaviorTypeData.BotType, player, botDefinition);
CreateActions(output, botData.BotActionsType);
CreateLogic(output, botData.LogicType, botDefinition.BehaviorSubtype);
if (botBuilder != null)
output.Init(botBuilder);
return output;
}