/* * TrapAI.cs * Authors: * Copyright (c) 2007-2008 Cornell University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; namespace StarJack { public class TrapAI:AI { bool collision; Type mTypeSearch; public Type TypeSearch { get { return mTypeSearch; } set{mTypeSearch = value;} } GameObject mTrap; public GameObject Trap { get { return mTrap; } set { mTrap = value; } } GameObject mCaught; public GameObject Caught { get { return mCaught; } set { mCaught = value; } } public TrapAI() : base() { mTypeSearch = typeof (Enemy); } public override void TakeTurn(int pTurn, bool deffered) { if (mCaught == null) { collision = mTrap.MyRoom.CheckCollision(mTrap, mTrap.Position); if (collision) { foreach (GameObject go in mTrap.MyRoom.PositionList[mTrap.Position[0], mTrap.Position[1]]) { Enemy ene = go as Enemy; if(ene != null) { mCaught = go; int[] newPos = new int[2]; if (Room.TILECOUNT / 2 >= go.Position[0]) { newPos[0] =-1; } else { newPos[0] = Room.TILECOUNT; } if (Room.TILECOUNT / 2 >= go.Position[1]) { newPos[1] = -1; } else { newPos[1] = Room.TILECOUNT; } go.TurnRoutines.Add(new MoveTurnRoutine(go,newPos)); // mCaught.AIEnable = false; } } if (mCaught != null) { mTrap.RemoveFromRoom(); } } } } public override void Reset() { mCaught = null; } } }