本文整理汇总了C#中IGameObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IGameObject.GetType方法的具体用法?C# IGameObject.GetType怎么用?C# IGameObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGameObject
的用法示例。
在下文中一共展示了IGameObject.GetType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Touches
public override void Touches(IGameObject entity)
{
if (entity.GetType() == typeof(Neko))
{
this.Destroyed = true;
// TODO: Update GameObject to use the Destroy() method instead.
}
}
示例2: OnGetBonus
public override void OnGetBonus(IGameObject obj)
{
if (obj.GetType() == typeof(Player))
{
Player player = (Player) obj;
player.AddShield(50);
Owner.RemoveObject(this);
}
}
示例3: Intersect
public override void Intersect(IGameObject obj)
{
if (obj.GetType() == typeof(Player))
{
Player player = (Player)obj;
player.TakeDMG(Damage);
Owner.RemoveObject(this);
}
}
示例4: Intersect
public override void Intersect(IGameObject obj)
{
base.Intersect(obj);
if (obj.GetType() == typeof(Bullet))
{
this.NeedToRemove = true;
var bullet = (Bullet)obj;
Owner.RemoveObject(bullet);
}
}
示例5: OnGetEnemy
public override void OnGetEnemy(IGameObject obj)
{
if (obj.GetType() == typeof(Player))
{
Player player = (Player)obj;
player.TakeDMG(+50);
Owner.RemoveObject(this);
}
}
示例6: OnButtonPressed
private void OnButtonPressed(object o, ButtonPressEventArgs args)
{
TreePath path = GetPathAtPos((int) args.Event.X, (int) args.Event.Y);
if (path == null) return;
TreeIter iter;
if(!Model.GetIter(out iter, path))
return;
currentObject = (IGameObject) Model.GetValue(iter, COL_OBJECT);
application.EditProperties(currentObject, currentObject.GetType().Name);
if(args.Event.Button == 3) {
ShowPopupMenu();
}
}
示例7: AddObject
public void AddObject(IGameObject obj)
{
if (obj != null)
{
if (obj.GetType() != typeof(Explosion))
{
obj.Owner = this;
obj.LoadContent(this.ResourceMgr);
this.objects.Add(obj);
}
else
{
this.Explosions.Add((Explosion)obj);
}
}
}
示例8: GetName
protected static string GetName(IGameObject obj, bool classname)
{
if ((!classname) && (obj is GameObject))
{
if (obj is Sim)
{
return (obj as Sim).Name;
}
else
{
try
{
string result = (obj as GameObject).ToTooltipString();
if (!string.IsNullOrEmpty(result))
{
return result;
}
}
catch (Exception e)
{
Common.Exception(obj, e);
}
}
}
string name = null;
name = obj.GetType().Namespace + "." + obj.GetType().Name;
name = name.Replace("Sims3.Gameplay.", "");
return name;
}
示例9: Intersect
public override void Intersect(IGameObject obj)
{
OnGetEnemy(obj);
if (obj.GetType() == typeof(Bullet))
{
var bullet = (Bullet)obj;
this.shooted--;
if (this.shooted < 0)
{
this.Health -= 2;
Owner.RemoveObject(bullet);
this.shooted = 10;
}
if (this.Health <= 0)
{
this.NeedToRemove = true;
Owner.RemoveObject(this.bossLaser);
this.ScoringPoints = 100;
}
}
}
示例10: SerializeIGameObject
/// <summary>
/// Serializes the given IGameObject (name, type, team).
/// </summary>
/// <param name="rootElement">The parent element.</param>
/// <param name="gameObject">The serializing IGameObject.</param>
private void SerializeIGameObject(XElement rootElement, IGameObject gameObject, string elementName)
{
var element = new XElement(elementName,
new XAttribute("name", gameObject.Name),
new XAttribute("type", gameObject.GetType().ToString().Split('.').Last()),
new XAttribute("team", gameObject.Team)
);
rootElement.Add(element);
foreach (var item in GetSortedArgsToSerialization(gameObject)) {
SerializeArgument(element, item.Value);
}
foreach (var item in gameObject.GetIGameActions()) {
SerializeGameAction(element, item);
}
}
示例11: CopyState
/// <summary>
/// Copies the current values of this object to a new object
/// </summary>
/// <param name="copyTo">The object that should have it's properties overwritten with the values of the calling Object</param>
public virtual void CopyState(ref IGameObject copyFrom, bool ignoreNonNullProperties = false)
{
PropertyInfo[] properties = copyFrom.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
foreach (PropertyInfo prop in properties)
{
PropertyInfo info = this.GetType().GetProperty(prop.Name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
// Check if this property has State Copy disabled via the custom attribute, if so, don't copy this property.
Attribute[] attrib = (Attribute[])info.GetCustomAttributes(typeof(DisableStateCopyAttribute), true);
if (attrib.Length > 0)
continue;
// If info is not null and we can write it without an exception
if (info != null && info.CanWrite)
{
// Check if this.Property already has a value.
// if it does, then check if the user wants to override it or not.
if (info.GetValue(this, null) != null && !ignoreNonNullProperties)
info.SetValue(this, prop.GetValue(copyFrom, null), null);
// If it does not have a value, then we set it regardless.
else if (info.GetValue(this, null) == null)
info.SetValue(this, prop.GetValue(copyFrom, null), null);
}
else
{
Log.Error(string.Format("Failed to get property {0} from object {1} within the {2}.CopyState method", prop.Name, copyFrom.Name, this.Name));
}
}
}
示例12: DebugObject
public DebugObject(IGameObject item)
{
this.item = item;
this.Attributes = new List<System.Reflection.PropertyInfo>(item.GetType().GetProperties());
this.Id = item.GetHashCode();
}