protected virtual void OnGo(object sender, GoEventArgs e) { if (Go != null) { Go(sender, e); } }
public void GoAnimal(object sender, GoEventArgs e) { Animal send = (sender as Animal);//если получится актор, делай его e.IsAnimPr = false; if (MCell[e.TargPos.X, e.TargPos.Y].LAnimal == null) { if (send.GetCanPlace(MCell[e.TargPos.X, e.TargPos.Y].ID, MCell[e.TargPos.X, e.TargPos.Y].LEnvir)) { if (MCell[e.CurPos.X, e.CurPos.Y].LAnimal == send) { if (e.CurPos.X / 16 != e.TargPos.X / 16 || e.CurPos.Y / 16 != e.TargPos.Y / 16) { this[e.TargPos / 16].Animals.Add(MCell[e.CurPos.X, e.CurPos.Y].LAnimal);//может добавляться null, надо удалять именно Sender this[e.CurPos / 16].Animals.Remove(MCell[e.CurPos.X, e.CurPos.Y].LAnimal); } MCell[e.TargPos.X, e.TargPos.Y].LAnimal = MCell[e.CurPos.X, e.CurPos.Y].LAnimal; MCell[e.CurPos.X, e.CurPos.Y].LAnimal = null; e.CanGo = true; } else { Console.WriteLine("Координаты животного и клетки не совпадают"); } } else { e.CanGo = false; } } else { e.IsAnimPr = true; e.CanGo = false; } }
public override void EvTick(float DTime) { TickAnim(DTime); ProcessAct(Configuration.Dtime); if (Health.alive == false) { return; } if (State == AnimState.Zero) //В этом случае надо думать, что делать { CntThink++; if (Targ.Count == 0)//Пришли, что дальше? { ThinkNew(); CntThink = 0; } else if (Targ[Targ.Count - 1] == Location || CntThink >= MaxCntTh) { //А правильно ли мы идём? CntThink = 0; Console.WriteLine("Думаютб"); if (Targ[Targ.Count - 1] == Location) { Targ.RemoveAt(Targ.Count - 1); } if (Targ.Count == 0 || Near && Targ.Count == 1) { ThinkNew(); CntThink = 0; } else { if (ThinkMed()) { GoEventArgs g = new GoEventArgs() { CurPos = Location, TargPos = Targ[Targ.Count - 1], }; if (!ActGo(g, false))//если не сможет пройти, думоем { ThinkNew(g.IsAnimPr); CntThink = 0; } } else { if (State == AnimState.Zero) { ThinkNew(); CntThink = 0; } } } } else { //Просто идём GoEventArgs g = new GoEventArgs() { CurPos = Location, TargPos = Targ[Targ.Count - 1], }; if (!ActGo(g, false)) //если не сможет пройти, думоем { ThinkNew(g.IsAnimPr); CntThink = 0; } } } }
protected virtual void OnGo(object sender, GoEventArgs e) { if (Go != null) Go(sender, e); }