Пример #1
0
        public static Order Lunge(Food f, float dt)
        {
            Point? original = null;
            float lerp = 0.0f;

            return a =>
                {
                    if (original == null) original = a.Position;
                    lerp += dt;

                    if (lerp > 1.0f) lerp = 1.0f;
                    a.Position = lerp.Lerp(original.Value, f.Position);

                    if (lerp >= 1.0f)
                    {
                        lerp = 1.0f;
                        f.Die();

                        var otherFoods = a.m.GetRoomAt(a.Position.ToSquare())
                            .Actors.OfType<Food>();

                        foreach (var x in otherFoods)
                            x.Panic(a.m);
                        return true;
                    }

                    return false;
                };
        }
Пример #2
0
        public static Order Eat(Food f)
        {
            return a =>
                {
                    if (a.Position.ToSquare() == f.Position.ToSquare())
                    {
                        // got eaten!
                        // todo: some animation bs
                        f.Die();

                        // alert all the other dudes!
                        var otherFoods = a.m.GetRoomAt(a.Position.ToSquare()).Actors.OfType<Food>();

                        foreach (var x in otherFoods)
                            x.Panic(a.m);

                        return true;
                    }
                    else
                    {
                        ((IOrderTarget)a).AcceptOrder(f.Position.ToSquare());
                        return false;
                    }
                };
        }