// assumes cell has been checked for any containing entities public void AddTrapEntity(Cell cell) { ICellEntity ent = new TrapEntity(cell); entities[cell.GetCellIndexX(), cell.GetCellIndexY()] = ent; GameObject go = Instantiate(prefabs[1], new Vector3(cell.getCenterPosition().x, cell.getCenterPosition().y, -2), Quaternion.identity); ent.gameObject = go; }
void CreateTrap(TrapEntity trapEntity) { Vector3 trapPosotion = new Vector3 { x = trapEntity.location.x, y = trapEntity.location.y, z = trapEntity.location.z }; GameObject newTrap = null; if (trapEntity.trapType == GameSettings.ICE_TRAP_TYPE) { newTrap = Instantiate(IceTrap, trapPosotion, new Quaternion(0, 0, 0, 1f)); } else if (trapEntity.trapType == GameSettings.NEEDLE_TRAP_TYPE) { newTrap = Instantiate(NeedleTrap, trapPosotion, new Quaternion(0, 0, 0, 1f)); } TrapControl trapControl = newTrap.GetComponent <TrapControl>(); trapControl.trapID = trapEntity.entityID; trapControl.trapType = trapEntity.trapType; trapControl.playerID = trapEntity.playerID; // if trap is not put by local player, then close the trigger if (trapEntity.playerID != GameSettings.playerID) { BoxCollider boxCollider = newTrap.GetComponent <BoxCollider>(); boxCollider.enabled = false; } // add collider to the trap from judge collider BoxCollider newCollider = newTrap.AddComponent <BoxCollider>(); newCollider.size = new Vector3(0.8f, 0.05f, 0.8f); newCollider.center = new Vector3(0, 0, 0); }
public static void disableTrapEntity(TrapEntity[] entitys) { foreach (TrapEntity entity in entitys) { disableTrapEntity(entity); } }
public static void disableTrapEntity(TrapEntity entity) { GameController.GameActionEvent.despawnObject(entity); entity.setActive(false); entity.Object = null; }
public CMD_SelfTrapActuation(MyCharacterController owner,TrapEntity trap) : base(owner) { Trap = trap; }
private void footcheck() { Collider2D[] items = getAllCollider(MyCharacterController.Direction.C, itemmask); OnItemEntity = items.Length != 0 ? items[0].GetComponent<ItemEntity>() : null; items = getAllCollider(MyCharacterController.Direction.C, trapmask); OnTrapEntity = items.Length != 0 ? items[0].GetComponent<TrapEntity>() : null; items = getAllCollider(MyCharacterController.Direction.C, gatemask); OnGateWayEntity = items.Length != 0 ? items[0].GetComponent<GateWayEntity>() : null; items = getAllCollider(MyCharacterController.Direction.C, tilemask); Array.Sort(items, (a, b) => SortingLayer.GetLayerValueFromName(b.transform.tag) - SortingLayer.GetLayerValueFromName(a.transform.tag)); OnTileEntity = items.Length != 0 ? items[0].GetComponent<TileEntity>() : null; }
Texture2D writeTrapPosition(Texture2D tex, TrapEntity[] traps) { int x, y; Color c = Trap;//new Color(GateWay.r, GateWay.g, GateWay.b, 0); foreach (TrapEntity trap in traps) { if (!trap.IsDetected) continue; x = (int)trap.Position.x; y = (int)trap.Position.y; tex.SetPixel(x, y, c); } tex.Apply(false); return tex; }
public TrapActuation(MyCharacterController target, TrapEntity trap) : base(target) { Trap = trap; }
public static TrapEntity[] getAllTraps() { var ret = new TrapEntity[Traps.childCount]; int i = 0; foreach (Transform t in Traps.transform) { ret[i++] = t.GetComponent<TrapEntity>(); } return ret; }
public SelectedTrapUseMenu(TrapEntity trap, PlayerController owner, Vector2 pos) : base(trap.Entity, owner, pos, new Vector2(1,1), "SelectedTrapUse") { setMenuLabels(); Trap = trap; }
public bool canExertion(PlayerController player) { var find = Physics2D.OverlapPoint(player.FrontPos, TagList.getLayerMask(TagList.Trap)); var c = Physics2D.OverlapPoint(player.FrontPos, TagList.getLayerMask(TagList.Character)); //GameController.PlayingLogger.addLogFormat("{0} {1} {2}",player.FrontPos,find==null,c==null); if (find != null && c == null) { Trap = find.GetComponent<TrapEntity>(); return true; }; return false; }
public void exertion(PlayerController player) { //GameController.PlayingLogger.addLog("Exertion!"); ObjectEntityFactory.disableTrapEntity(Trap); Trap = null; if (canBreakEquipment()) { player.removeInventoryItem(Equipment); GameController.SoundController.playSE(SoundNameList.SE_BangleBroke); IsBreakEquipment = true; } else { IsBreakEquipment = false; ExertionCount += 1; CurrentFailureRate = calcFailureRate(); } }