Example #1
0
        public Dikabryozik(Point position)
        {
            IsPassable = false;

            Size = new Size(1, 1);

            Id = 0x00018000;

            Speed = 10;

            ViewRadius = 3;
            ViewSight = new Size((uint)ViewRadius, (uint)ViewRadius);
            Position = position;

            _bundle = new Bag(2, 2);

            ObjectWithState = new ObjectWithState(
                new List<IObjectState>
                    {
                        new Staying() {TickCount = STAYING_BASE_TICKCOUNT, Distribution = STAYING_BASE_TICKCOUNT/10, Eternal = false},
                        new Hungry() {TickCount = 300, Distribution = 30, Eternal = true}
                    },
                    false, null, OnChangeState);

            this.StateEvent.FireEvent();
        }
Example #2
0
        //  private List<PointWithDistance> _visibleCells;

        protected Animal(bool isPassable, Size size, uint id, uint speed, string name, int viewRadius, Point position)
        {
            IsPassable = isPassable;

            Size = size;

            Id = id;

            Speed = speed;

            Name = name;

            ViewRadius = viewRadius;
            ViewSight  = new Size((uint)ViewRadius, (uint)ViewRadius);
            Position   = position;

            ObjectWithState = new ObjectWithState(
                new List <ObjectState>
            {
                new ObjectState(ObjectStates.ObjectStates.Staying)
                {
                    TickCount = STAYING_BASE_TICKCOUNT, Distribution = STAYING_BASE_TICKCOUNT / 10, Eternal = false
                },
                new ObjectState(ObjectStates.ObjectStates.Hungry)
                {
                    TickCount = 300, Distribution = 30, Eternal = true
                }
            },
                false, null, OnChangeState);

            StateEvent.FireEvent();
        }
Example #3
0
 public void RemoveObjectFromQueue(ObjectWithState objectWithState)
 {
     // should be done with locking
     lock (lockObject)
     {
         _queue.Remove(objectWithState);
     }
 }
Example #4
0
 public void OnLastStateFinished()
 {
     CurrentCount = Math.Min(CurrentCount + 1, TotalCount);
     if (CurrentCount < TotalCount)
     {
         ObjectWithState.ChangeState(0);
     }
 }
Example #5
0
 public void AddObjectToQueue(int nextStateInterval, int distribution, ObjectWithState objectWithState)
 {
     // should be done with locking
     lock (lockObject)
     {
         objectWithState.NextStateTick = CurrentTick + nextStateInterval + 2 * distribution - (int)(distribution * Random.NextDouble());
         _queue.Add(objectWithState);
     }
 }
Example #6
0
        public Mushroom()
        {
            IsPassable = true;

            Size = new Size(1, 1);

            Id = 0x00001900;

            ObjectWithState =
                new ObjectWithState(
                    new List<IObjectState>
                    {
                        new Growing {TickCount = 300, Distribution = 50, Eternal = false},
                        new Staying{TickCount = 1000, Distribution = 100, Eternal = false}
                    },
                    false,
                    OnLastStateFinished);
        }
Example #7
0
File: Fire.cs Project: norniel/Game
        public Fire()
        {
            IsPassable = false;

            Size = new Size(1, 1);

            Id = 0x00000600;

            ObjectWithState =
                new ObjectWithState(
                    new List<IObjectState>
                    {
                        new Firing {TickCount = 300, Distribution = 10, Eternal = false},
                        new Attenuating {TickCount = 150, Distribution = 10, Eternal = false}
                    },
                    false,
                    OnLastStateFinished);
        }
Example #8
0
        public CollectBehavior(string name, int perCollectCount, int totalCount, bool isRegrowable = true)
        {
            _isRegrowable   = isRegrowable;
            Name            = name;
            PerCollectCount = perCollectCount;
            TotalCount      = totalCount;
            CurrentCount    = totalCount;

            if (_isRegrowable)
            {
                ObjectWithState =
                    new ObjectWithState(
                        new List <ObjectState>
                {
                    new ObjectState(ObjectStates.ObjectStates.Growing, new ObjStateProperties {
                        TickCount = DayNightCycle.HalfDayLength, Distribution = DayNightCycle.HalfDayLength, Eternal = false
                    })
                },
                        false,
                        OnLastStateFinished, null, true);
            }
        }
Example #9
0
 public void Eat(int satiety)
 {
     ObjectWithState.ChangeState(0, STAYING_BASE_TICKCOUNT + (int)(STAYING_BASE_TICKCOUNT * satiety * 0.1));
 }