void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Obstacle")) { ship.Crash(); } if (collision.gameObject.CompareTag("PickUp")) { drop = collision.gameObject.GetComponent <DropBehavior>(); if (drop.type == DropBehavior.TypeDrop.Health) { health.changeHealth(collision.gameObject.GetComponent <DropBehavior>().value * 100); } if (drop.type == DropBehavior.TypeDrop.Uranium) { uranium.addUranium(collision.gameObject.GetComponent <DropBehavior>().value); } Destroy(collision.gameObject); } if (collision.gameObject.CompareTag("EnemyProjectile")) { health.changeHealth(-collision.gameObject.GetComponent <LaserBehavior>().damage); collision.gameObject.GetComponent <LaserBehavior>().explose(); } if (collision.gameObject.CompareTag("BossProjectile")) { health.changeHealth(-collision.gameObject.GetComponent <BossProjectile>().damage); Destroy(collision.gameObject); } if (collision.gameObject.CompareTag("Enemy")) { collision.gameObject.GetComponent <EnemyShipBehavior>().DestroyShip(); health.changeHealth(-25); } }
public DropBehavior CreateDrop(uint sceneid, string uid, int entityType, GameObject go) { DropBehavior t = go.GetComponent <DropBehavior>(); if (t == null) { t = go.AddComponent <DropBehavior>(); } entityBehaviors.Add(uid, t); t.uid = uid; t.entityType = entityType; t.sceneid = sceneid; t.OnNewObject(); return(t); }
static int CreateDrop(IntPtr L) { try { ToLua.CheckArgsCount(L, 5); EntityBehaviorMgr obj = (EntityBehaviorMgr)ToLua.CheckObject(L, 1, typeof(EntityBehaviorMgr)); uint arg0 = (uint)LuaDLL.luaL_checknumber(L, 2); string arg1 = ToLua.CheckString(L, 3); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); UnityEngine.GameObject arg3 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 5, typeof(UnityEngine.GameObject)); DropBehavior o = obj.CreateDrop(arg0, arg1, arg2, arg3); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public bool AllowDropWithPossibleDataLoss(ObjectState dropItem, DropBehavior dropBehavior) { // If we're skipping drops then no drops are allowed. if (dropBehavior == DropBehavior.SkipDrop) { return(false); } // If we're allowing data loss without prompting then it's permitted. if (!Options.PromptForPossibleDataLoss) { return(true); } if (Output.CanPrompt) { doStepAction(); // If the user allows it then it's allowed. if (Output.Prompt(OutputMode.Warning, "About to drop " + dropItem + ". All data in this " + dropItem.ObjectType + " will be lost!", "Are you sure?")) { return(true); } } // We're not going to allow the drop; if (dropBehavior == DropBehavior.Drop) { Fail("Dropping " + dropItem + " may cause data loss."); } else { output.Verbose("Skipping drop of " + dropItem); } return(false); }