Exemplo n.º 1
0
            /// <summary>
            /// Call this to change the life status. This function will block
            /// until all callback functions have returned
            /// </summary>
            /// <param name="NewStat"></param>
            public void ChangeStatus(LifeStatus NewStat)
            {
                Queue <FinishCall> q = new Queue <FinishCall>();

                lock (theLock)
                {
                    //call them all
                    foreach (StatusCallback b in callbacks)
                    {
                        FinishCall tcall = new FinishCall();
                        try
                        {
                            tcall.result = b.BeginInvoke(_status, null, null);
                        }
                        catch { }
                        tcall.callback = b;
                        q.Enqueue(tcall);
                    }

                    //wait for them all to complete:
                    foreach (FinishCall tcall in q)
                    {
                        try
                        {
                            tcall.callback.EndInvoke(tcall.result);
                        }
                        catch { }
                    }
                }
            }
Exemplo n.º 2
0
        public Life(string name, string arg)
        {
            this.name = name;
            try
            {
                process = new Process();
                process.StartInfo.FileName               = Config.LifePool + "//" + name;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardInput  = false;
                process.StartInfo.RedirectStandardOutput = false;
                process.StartInfo.Arguments              = arg;
                process.StartInfo.RedirectStandardError  = false;
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                //process.StartInfo.WorkingDirectory = Config.LifePool;
                process.EnableRaisingEvents   = true;
                process.StartInfo.ErrorDialog = false;
                process.Exited += new EventHandler(myProcess_Exited);

                process.Start();
                process.WaitForExit(5000);
                status = LifeStatus.ALIVE;
            }
            catch (Exception e)
            {
                status = LifeStatus.DEAD;
            }
        }
Exemplo n.º 3
0
        public void DetermineNextStatusAndClearFood(int foodToSurvive, int foodToReproduce)
        {
            if (Health <= 0.0)
            {
                NextStatus = LifeStatus.Die;
            }
            else
            {
                switch (FoodCollected)
                {
                case var d when d < foodToSurvive:
                    NextStatus = LifeStatus.Die;
                    break;

                case var d when d >= foodToSurvive && d < foodToReproduce:
                    NextStatus = LifeStatus.StayAlive;
                    break;

                case var d when d >= foodToReproduce:
                    NextStatus = LifeStatus.Reproduce;
                    break;
                }
            }

            FoodCollectedLastDay = FoodCollected;
            FoodCollected        = 0;
        }
Exemplo n.º 4
0
        public ViewResult AdvancedList(string name, LifeStatus status, Sex sex)
        {
            var view = View("List", new MainModel(FilterByParameters(name, status, sex), Request.RawUrl, UserVoted()));

            view.ViewBag.Name       = name;
            view.ViewBag.LifeStatus = status;
            view.ViewBag.Sex        = sex;
            return(view);
        }
Exemplo n.º 5
0
 public CreatureDTO(Creature source)
 {
     Id            = source.Id;
     Health        = source.Health;
     CreatureType  = source.CreatureType;
     FoodCollected = source.FoodCollected;
     NextStatus    = source.NextStatus;
     Position      = new Coordinate(source.Position);
 }
Exemplo n.º 6
0
        public ViewResult List(string name, LifeStatus status, Sex sex)
        {
            var backUrl = string.Format("/Character/AdvancedList?name={0}&status={1}&sex={2}", name, status, sex);
            var view    = View(new MainModel(FilterByParameters(name, status, sex), backUrl, UserVoted()));

            view.ViewBag.Name       = name;
            view.ViewBag.LifeStatus = status;
            view.ViewBag.Sex        = sex;
            return(view);
        }
Exemplo n.º 7
0
Arquivo: Life.cs Projeto: sgyan19/God
 public Life(string dna)
 {
     this.dna  = dna;
     status    = LifeStatus.BORNING;
     exe_name  = dna + ".exe";
     dna_path  = Config.AliveDir + "\\" + dna;
     exe_path  = Config.AliveDir + "\\" + EXEName;
     incubator = new Incubator();
     incubator.AsyncBorn(dna_path, exe_path);
 }
Exemplo n.º 8
0
Arquivo: Life.cs Projeto: sgyan19/God
 private void CheckOut()
 {
     status = process.ExitCode == 0 ? LifeStatus.HEAVEN : LifeStatus.DEAD;
     if (status == LifeStatus.HEAVEN)
     {
         Console.WriteLine(dna + " is  goto heaven!");
     }
     else
     {
         Console.WriteLine(dna + " is  dead!");
     }
 }
Exemplo n.º 9
0
        void handleDying()
        {
            _dyingFramePointer += .15f;

            if (_dyingFramePointer > _dyingFrames.Count)
            {
                _lifeStatus = LifeStatus.Dead;
            }
            else
            {
                _spriteSheetPos = _dyingFrames[(int)Math.Floor(_dyingFramePointer)];
            }
        }
Exemplo n.º 10
0
Arquivo: Life.cs Projeto: sgyan19/God
        public bool Live()
        {
            if (status == LifeStatus.BORNING)
            {
                var boResult = incubator.CheckResult();
                if (boResult == null)
                {
                    return(true);
                }

                if (boResult == true && File.Exists(EXEPath))
                {
                    Console.WriteLine(dna + " is borned!");
                    try
                    {
                        process = new Process();
                        process.StartInfo.FileName               = exe_name;
                        process.StartInfo.UseShellExecute        = true;
                        process.StartInfo.RedirectStandardInput  = false;
                        process.StartInfo.RedirectStandardOutput = false;
                        process.StartInfo.RedirectStandardError  = false;
                        process.StartInfo.CreateNoWindow         = true;
                        process.StartInfo.WorkingDirectory       = Config.AliveDir;
                        process.EnableRaisingEvents              = true;
                        process.Exited += new EventHandler(myProcess_Exited);

                        process.Start();
                        status = LifeStatus.ALIVE;
                        return(true);
                    } catch (Exception e)
                    {}
                }
                Console.WriteLine(dna + " borned failed!");
                status = LifeStatus.DEAD;
                return(false);
            }
            if (status == LifeStatus.ALIVE)
            {
                try
                {
                    CheckOut();
                    return(false);
                } catch (InvalidOperationException)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Mark Object LifeStatus
        /// </summary>
        protected void MarkLifeStatus(LifeStatus status)
        {
            _lifeStatus = status;
            switch (status)
            {
            case LifeStatus.Stored:
                StoredData = (T)MemberwiseClone();
                break;

            case LifeStatus.New:
            case LifeStatus.Remove:
                StoredData = default(T);
                break;
            }
        }
Exemplo n.º 12
0
 private void CheckExitCode()
 {
     status = process.ExitCode == 0 ? LifeStatus.HEAVEN : LifeStatus.DEAD;
     if (status == LifeStatus.HEAVEN)
     {
         Nwa.logInfo.Info(name + " is  goto heaven!");
     }
     else
     {
         Nwa.logInfo.Info(name + " is  dead!");
     }
     try
     {
         process.Kill();
     }
     catch (Exception e) { }
 }
Exemplo n.º 13
0
        void resetAll(bool isDemoMode = false)
        {
            Visible = true;
            _demoKeyPresses.Reset();
            _isDemoMode        = isDemoMode;
            _direction         = Directions.Left;
            _speed             = Constants.PacManBaseSpeed;
            _dyingFramePointer = 0;
            Position           = Tile.ToCenterCanvas(new Vector2(13.5f, 23));
            _lifeStatus        = LifeStatus.Alive;

            _animDirection     = new TwoFrameAnimation(65.Milliseconds());
            _frame1InSpriteMap = _framePointers[_direction].Frame1;
            _frame2InSpriteMap = _framePointers[_direction].Frame2;

            _spriteSheetPos = _frame1InSpriteMap;
        }
Exemplo n.º 14
0
    protected void ProcessDamageEvent(ref DamageEvent damage)
    {
        if (this.takenodamage)
        {
            return;
        }
        LifeStatus lifeStatu = damage.status;

        if (lifeStatu == LifeStatus.IsAlive)
        {
            TakeDamage takeDamage = this;
            takeDamage._health = takeDamage._health - damage.amount;
        }
        else if (lifeStatu == LifeStatus.WasKilled)
        {
            this._health = 0f;
        }
    }
Exemplo n.º 15
0
    protected override LifeStatus Hurt(ref DamageEvent damage)
    {
        LifeStatus status = base.Hurt(ref damage);

        if ((damage.damageTypes & (DamageTypeFlags.damage_explosion | DamageTypeFlags.damage_melee | DamageTypeFlags.damage_bullet)) != 0)
        {
            this._healOverTime = 0f;
        }
        if (status == LifeStatus.WasKilled)
        {
            base.CancelInvoke("DoBleed");
            return(status);
        }
        if ((status == LifeStatus.IsAlive) && (base.healthLossFraction > 0.2f))
        {
            float num = damage.amount / base.maxHealth;
            if (((damage.damageTypes & (DamageTypeFlags.damage_melee | DamageTypeFlags.damage_bullet)) == 0) || (damage.amount <= (base.maxHealth * 0.05f)))
            {
                return(status);
            }
            int max = 0;
            if (num >= 0.25f)
            {
                max = 1;
            }
            else if (num >= 0.15f)
            {
                max = 2;
            }
            else if (num >= 0.05f)
            {
                max = 3;
            }
            if ((Random.Range(0, max) == 1) || (max == 1))
            {
                this.AddBleedingLevel(Mathf.Clamp(damage.amount * 0.15f, 1f, base.maxHealth));
                this.bleedAttacker = damage.attacker.id;
                this.bleedingID    = damage.victim.id;
            }
        }
        return(status);
    }
Exemplo n.º 16
0
        public PacMan(IMaze maze, IHumanInterfaceParser input, IMediator mediator)
        {
            _maze           = maze;
            _input          = input;
            _mediator       = mediator;
            _demoKeyPresses = new DemoKeyPresses();

            _lifeStatus = LifeStatus.Alive;

            _tile = new Tile();

            _keyPress      = new KeyPressedEvent();
            _framePointers = new Dictionary <Directions, FramePointers>();

            const int left  = 456;
            const int left2 = 472;

            _framePointers[Directions.Up] = new FramePointers(
                new Vector2(left, 32), new Vector2(left2, 32));

            _framePointers[Directions.Down] = new FramePointers(
                new Vector2(left, 48), new Vector2(left2, 48));

            _framePointers[Directions.Left] = new FramePointers(
                new Vector2(left, 16), new Vector2(left2, 16));

            _framePointers[Directions.Right] = new FramePointers(
                new Vector2(left, 0), new Vector2(left2, 0));

            _dyingFrames       = new List <Vector2>();
            _dyingFramePointer = 0;

            for (var i = 0; i < 12; i++)
            {
                _dyingFrames.Add(new Vector2(489 + i * 16, 0));
            }

            _animDirection = new TwoFrameAnimation(65.Milliseconds());

            Reset();
        }
Exemplo n.º 17
0
    protected override LifeStatus Hurt(ref DamageEvent damage)
    {
        LifeStatus lifeStatu = base.Hurt(ref damage);

        if ((int)(damage.damageTypes & (DamageTypeFlags.damage_bullet | DamageTypeFlags.damage_melee | DamageTypeFlags.damage_explosion)) != 0)
        {
            this._healOverTime = 0f;
        }
        if (lifeStatu == LifeStatus.WasKilled)
        {
            base.CancelInvoke("DoBleed");
        }
        else if (lifeStatu == LifeStatus.IsAlive && base.healthLossFraction > 0.2f)
        {
            float single = damage.amount / base.maxHealth;
            if ((int)(damage.damageTypes & (DamageTypeFlags.damage_bullet | DamageTypeFlags.damage_melee)) != 0 && damage.amount > base.maxHealth * 0.05f)
            {
                int num = 0;
                if (single >= 0.25f)
                {
                    num = 1;
                }
                else if (single >= 0.15f)
                {
                    num = 2;
                }
                else if (single >= 0.05f)
                {
                    num = 3;
                }
                if ((UnityEngine.Random.Range(0, num) == 1 ? true : num == 1))
                {
                    this.AddBleedingLevel(Mathf.Clamp(damage.amount * 0.15f, 1f, base.maxHealth));
                    this.bleedAttacker = damage.attacker.id;
                    this.bleedingID    = damage.victim.id;
                }
            }
        }
        return(lifeStatu);
    }
Exemplo n.º 18
0
        public Creature(Creature source)
        {
            Id = source.Id;

            Health       = source.Health;
            AttackPower  = source.AttackPower;
            MaxSpeed     = source.MaxSpeed;
            Reach        = source.Reach;
            CreatureType = source.CreatureType;

            FoodCollected        = 0;
            FoodCollectedLastDay = 0;
            NextStatus           = LifeStatus.StayAlive;

            _randomGen = new Random(Guid.NewGuid().GetHashCode());

            Position = new Coordinate(source.Position);

            FoodInReachIds       = new List <int>(source.FoodInReachIds);
            CreaturesInReachIds  = new List <int>(source.CreaturesInReachIds);
            ReachingCreaturesIds = new List <int>(source.ReachingCreaturesIds);
        }
Exemplo n.º 19
0
        public Creature(int id, ICreatureType creatureType)
        {
            Id = id;

            CreatureType = creatureType;

            Health      = creatureType.Health;
            AttackPower = creatureType.AttackPower;
            MaxSpeed    = creatureType.MaxSpeed;
            Reach       = creatureType.Reach;
            Energy      = creatureType.Energy;

            FoodCollected        = 0;
            FoodCollectedLastDay = 0;
            NextStatus           = LifeStatus.StayAlive;

            _randomGen = new Random(Guid.NewGuid().GetHashCode());

            Position = new Coordinate(0.0, 0.0);

            FoodInReachIds       = new List <int>();
            CreaturesInReachIds  = new List <int>();
            ReachingCreaturesIds = new List <int>();
        }
Exemplo n.º 20
0
 public void BecomeStarting()
 {
     _Life = LifeStatus.Starting; _StartingTime = 0;
 }
Exemplo n.º 21
0
 public void die()
 {
     lifeStatus = LifeStatus.Dead;
 }
Exemplo n.º 22
0
        public void Update()
        {
            if(_Life == LifeStatus.Preparing || _Life == LifeStatus.Starting)
            {
                if (_StartingTime > STARTING_TIME_LIMIT) _Life = LifeStatus.Playing;	// 開始する

                Clear();
                _StartingTime += Time.deltaTime;
                return;
            }

            Damp();
        }
Exemplo n.º 23
0
 public void BecomePlaying()
 {
     _Life = LifeStatus.Playing;
 }
Exemplo n.º 24
0
 private static void setCellValueFor(LifeStatus[,] nextViewOfTheBoard, int rowIndex, int columnIndex, LifeStatus aliveOrDeadOnNextTick)
 {
     nextViewOfTheBoard[rowIndex, columnIndex] = aliveOrDeadOnNextTick;
 }
Exemplo n.º 25
0
        public HurtEvent(ref DamageEvent d)
        {
            //Logger.LogDebug(string.Format("[DamageEvent] {0}", d.ToString()));
            try
            {
                this._sleeper    = false;
                this.DamageEvent = d;
                this.WeaponData  = null;
                this.IsDecay     = false;
                this._status     = d.status;
                string weaponName = "Unknown";
                if (d.victim.idMain is DeployableObject)
                {
                    if (d.victim.id.ToString().ToLower().Contains("sleeping"))
                    {
                        this._sleeper = true;
                        DeployableObject sleeper = d.victim.idMain as DeployableObject;
                        this.Victim = new Sleeper(sleeper);
                    }
                    else
                    {
                        this.Victim = new Entity(d.victim.idMain.GetComponent <DeployableObject>());
                    }
                    this._playervictim = false;
                }
                else if (d.victim.idMain is StructureComponent)
                {
                    this.Victim        = new Entity(d.victim.idMain.GetComponent <StructureComponent>());
                    this._playervictim = false;
                }
                else if (d.victim.id is SpikeWall)
                {
                    this._playerattacker = false;
                    this.Victim          = new Entity(d.victim.idMain.GetComponent <DeployableObject>());
                }
                else if (d.victim.client != null)
                {
                    this.Victim        = Fougerite.Server.Cache[d.victim.client.userID];
                    this._playervictim = true;
                }
                else if (d.victim.character != null)
                {
                    this.Victim        = new NPC(d.victim.character);
                    this._playervictim = false;
                }
                if (!(bool)d.attacker.id)
                {
                    if (d.victim.client != null)
                    {
                        weaponName           = this.DamageType;
                        this._playerattacker = false;
                        this.Attacker        = null;
                    }
                }
                else if (d.attacker.id is SpikeWall)
                {
                    this._playerattacker = false;
                    this.Attacker        = new Entity(d.attacker.idMain.GetComponent <DeployableObject>());
                    weaponName           = d.attacker.id.ToString().Contains("Large") ? "Large Spike Wall" : "Spike Wall";
                }
                else if (d.attacker.id is SupplyCrate)
                {
                    this._playerattacker = false;
                    this.Attacker        = new Entity(d.attacker.idMain.gameObject);
                    weaponName           = "Supply Crate";
                }
                else if (d.attacker.id is Metabolism && d.victim.id is Metabolism)
                {
                    //this.Attacker = Fougerite.Server.Cache[d.attacker.client.userID];
                    this.Attacker        = Fougerite.Player.FindByPlayerClient(d.attacker.client);
                    this._playerattacker = false;
                    this.Victim          = this.Attacker;
                    ICollection <string> list = new List <string>();
                    Fougerite.Player     vic  = this.Victim as Fougerite.Player;
                    if (vic.IsStarving)
                    {
                        list.Add("Starvation");
                    }
                    if (vic.IsRadPoisoned)
                    {
                        list.Add("Radiation");

                        /*if (vic.RadLevel > 5000)
                         * {
                         *  vic.AddRads(-vic.RadLevel);
                         *  d.amount = 0;
                         *  _de.amount = 0;
                         *  Logger.LogDebug("[RadiationHack] Someone tried to kill " + vic.Name + " with radiation hacks.");
                         * }*/
                    }
                    if (vic.IsPoisoned)
                    {
                        list.Add("Poison");
                    }
                    if (vic.IsBleeding)
                    {
                        list.Add("Bleeding");
                    }

                    if (list.Contains("Bleeding"))
                    {
                        if (this.DamageType != "Unknown" && !list.Contains(this.DamageType))
                        {
                            list.Add(this.DamageType);
                        }
                    }
                    if (list.Count > 0)
                    {
                        weaponName = string.Format("Self ({0})", string.Join(",", list.ToArray()));
                    }
                    else
                    {
                        weaponName = this.DamageType;
                    }
                }
                else if (d.attacker.client != null)
                {
                    this.Attacker        = Fougerite.Server.Cache[d.attacker.client.userID];
                    this._playerattacker = true;
                    if (d.extraData != null)
                    {
                        WeaponImpact extraData = d.extraData as WeaponImpact;
                        this.WeaponData = extraData;
                        if (extraData.dataBlock != null)
                        {
                            weaponName = extraData.dataBlock.name;
                        }
                    }
                    else
                    {
                        if (d.attacker.id is TimedExplosive)
                        {
                            weaponName = "Explosive Charge";
                        }
                        else if (d.attacker.id is TimedGrenade)
                        {
                            weaponName = "F1 Grenade";
                        }
                        else
                        {
                            weaponName = "Hunting Bow";
                        }
                        if (d.victim.client != null)
                        {
                            if (!d.attacker.IsDifferentPlayer(d.victim.client) && !(this.Victim is Entity))
                            {
                                weaponName = "Fall Damage";
                            }
                            else if (!d.attacker.IsDifferentPlayer(d.victim.client) && (this.Victim is Entity))
                            {
                                weaponName = "Hunting Bow";
                            }
                        }
                    }
                }
                else if (d.attacker.character != null)
                {
                    this.Attacker        = new NPC(d.attacker.character);
                    this._playerattacker = false;
                    weaponName           = string.Format("{0} Claw", (this.Attacker as NPC).Name);
                }
                this.WeaponName = weaponName;
            }
            catch (Exception ex)
            {
                Logger.LogDebug(string.Format("[HurtEvent] Error. " + ex.ToString()));
            }
        }
Exemplo n.º 26
0
 public Cell(LifeStatus lifeStatus)
 {
     _lifeStatus = lifeStatus;
 }
Exemplo n.º 27
0
        public LifeStatus LifeStatusForNextTick(DeadOrAliveNeighboursCount deadOrAliveNeighbourCounts, LifeStatus currentLifeStatusOfCell)
        {
            if (currentLifeStatusOfCell == LifeStatus.Dead && deadOrAliveNeighbourCounts.AliveNeighbourCount > 3)
            {
                return(LifeStatus.Alive);
            }

            if (currentLifeStatusOfCell == LifeStatus.Alive &&
                (deadOrAliveNeighbourCounts.AliveNeighbourCount == 2 ||
                 deadOrAliveNeighbourCounts.AliveNeighbourCount == 3))
            {
                return(LifeStatus.Alive);
            }

            return(LifeStatus.Dead);
        }
Exemplo n.º 28
0
        public static void SetStatus(this IAgent agent, LifeStatus status)
        {
            var a = agent.Face <ILifeCycleAgent>();

            a.LifeStatus = status.ToString();
        }
Exemplo n.º 29
0
 public void recover()
 {
     currentHealth = 0;
     lifeStatus    = LifeStatus.Unconscious;
 }
Exemplo n.º 30
0
 public static void SetStatus(this IAgent agent, LifeStatus status)
 {
     var a = agent.Face<ILifeCycleAgent>();
     a.LifeStatus = status.ToString();
 }
Exemplo n.º 31
0
 public void StartDying()
 {
     _lifeStatus = LifeStatus.Dying;
 }
Exemplo n.º 32
0
 public void StartDigesting()
 {
     _lifeStatus = LifeStatus.BeingDigested;
 }
Exemplo n.º 33
0
 public RowColumnLifeStatus(int row, int column, LifeStatus lifeStatus)
 {
     Row        = row;
     Column     = column;
     LifeStatus = lifeStatus;
 }
Exemplo n.º 34
0
 public List <Character> FilterByParameters(string name, LifeStatus status, Sex sex)
 {
     return(repository.Characters
            .Where(c => c.Name.Contains(name) && c.LifeStatus == status && c.Sex == sex).ToList());
 }