Esempio n. 1
0
        public void Update(TimeObject timeObject)
        {
            ScreenEffects.Update(timeObject);
            SpriteTrail.Update(timeObject);
            ParticleManager.Update(timeObject);
            _world.Update(timeObject);
            JamUtilities.Camera.DoCameraMovement(timeObject);

            List <Tribe> templist = new List <Tribe>();

            foreach (var t in _tribeList)
            {
                t.Update(timeObject);
                if (!t.IsDead())
                {
                    templist.Add(t);
                }
                else
                {
                    if (t.Equals(_tribeList[0]))
                    {
                        _playerTribeDead = true;
                    }
                }
            }
            _tribeList = templist;
        }
Esempio n. 2
0
        public override IWorldObject Clone()
        {
            TimeObject res = new TimeObject(Word);

            res.Copy(this);
            return(res);
        }
Esempio n. 3
0
        public void Update(TimeObject timeObject)
        {
            _intelligence.DoIntelligenceUpdate(timeObject);

            _temperatureCheckTimer -= timeObject.ElapsedGameTime;
            if (_temperatureCheckTimer <= 0)
            {
                _temperatureCheckTimer += _temperatureCheckTimerMax * (1.0f + ((float)(RandomGenerator.Random.NextDouble() - 0.5) * 0.5f));
                DoCheckTemperature();
                DoCheckTerrain();
            }

            _foodTimer -= timeObject.ElapsedGameTime;
            if (_foodTimer <= 0)
            {
                _foodTimer += MoveTimerMax * (1.0f + ((float)(RandomGenerator.Random.NextDouble() - 0.5) * 0.5f));
                EatFood();
            }


            if (_fuckDeadTime >= 0)
            {
                _fuckDeadTime -= timeObject.ElapsedGameTime;
            }
            if (_fuckDeadTime < 0)
            {
                if (Tribe.TwoAnimalOnPosition(PositionInTiles))
                {
                    FuckIt();
                }
            }
        }
Esempio n. 4
0
        public void RunTimer()
        {
            TimeObject TimeObj = new TimeObject();

            TimeObj.enable = true;
            TimeObj.count  = 1;

            TimerCallback TimerDelegate = new TimerCallback(TimerTask);

            Timer TimerItem = new Timer(TimerDelegate, TimeObj, 2000, delay);

            TimeObj.timer = TimerItem;
            TimeSpan span1 = TimeSpan.FromMinutes(this.minutes);

            if (!infi)
            {
                while (TimeObj.count < max_count)
                {
                    Thread.Sleep(span1);
                }
            }
            else
            {
                while (true)
                {
                    Thread.Sleep(span1);
                }
            }

            TimeObj.enable = false;
        }
Esempio n. 5
0
        public void RunTimer()
        {
            TimeObject TimeObj = new TimeObject();
            TimeObj.enable = true;
            TimeObj.count = 1;

            TimerCallback TimerDelegate = new TimerCallback(TimerTask);

            Timer TimerItem = new Timer(TimerDelegate, TimeObj, 2000, delay);

            TimeObj.timer = TimerItem;
            TimeSpan span1 = TimeSpan.FromMinutes(this.minutes);

            if (!infi)
            {
                while (TimeObj.count < max_count)
                {
                    Thread.Sleep(span1);
                }
            }
            else
            {
                while (true)
                {
                    Thread.Sleep(span1);
                }
            }

            TimeObj.enable = false;
        }
Esempio n. 6
0
        public void Update(TimeObject timeObject)
        {
            _numberOfAnimalsToSpawnThisRound = 0;
            Vector2f newCenterPosition = new Vector2f(0, 0);

            List <Animal> newAnimalList = new List <Animal>();

            foreach (Animal a in _animalList)
            {
                a.Update(timeObject);
                newCenterPosition += new Vector2f(a.PositionInTiles.X, a.PositionInTiles.Y);

                if (!a.IsDead())
                {
                    newAnimalList.Add(a);
                }
            }
            newCenterPosition /= _animalList.Count;
            PositionInTiles    = new Vector2i((int)newCenterPosition.X, (int)newCenterPosition.Y);

            _animalList = newAnimalList;

            //Console.WriteLine("TotalHealth : " + GetSummedCurrentHealth() + "\t/\t" + GetSummedMaxHealth() + "\t" + "\t" + GetSummedCurrentHealth() / GetSummedMaxHealth()* 100.0f  + "\t" + _animalList.Count);

            for (int i = 0; i != _numberOfAnimalsToSpawnThisRound; ++i)
            {
                SpawnAnimal();
            }
        }
Esempio n. 7
0
        public override void Update(TimeObject timeObject)
        {
            base.Update(timeObject);

            //Console.WriteLine("gs: " + shp.Scale.X.ToString());

            if (Input.pressed[Keyboard.Key.D])
            {
                GP.WindowGameView.Move(new Vector2f(100 * timeObject.ElapsedGameTime, 0));
            }
            else if (Input.pressed[Keyboard.Key.A])
            {
                GP.WindowGameView.Move(new Vector2f(-100 * timeObject.ElapsedGameTime, 0));
            }

            if (Input.justPressed[Keyboard.Key.K])
            {
                JamUtilities.Tweens.ShapeScaleTween.createShapeTween(shp, 2, 2, null, PennerDoubleAnimation.EquationType.CubicEaseIn);
            }

            if (Input.justPressed[Keyboard.Key.L])
            {
                JamUtilities.Tweens.ShapeScaleTween.createShapeTween(shp, -0.5f, 2, null, PennerDoubleAnimation.EquationType.SineEaseOut);
            }
        }
Esempio n. 8
0
    public void OnTriggerEnter(Collider other)
    {
        TimeObject to = other.GetComponent <TimeObject>();

        if (to != null)
        {
            to.Kill(GameManager.time);
        }
    }
Esempio n. 9
0
 protected override void DoUpdate(TimeObject timeObject)
 {
     while (_inverseFrequency <= 0.0f)
     {
         SpawnDarkenObject();
         //_inverseFrequency *= 0.5f;
         _inverseFrequency += _inverseFrequencyTotal;
     }
 }
Esempio n. 10
0
    public void ShouldConvertFromJson()
    {
        var timeObj = new TimeObject {
            Time = new Time(15, 45)
        };
        var serialized   = XtiSerializer.Serialize(timeObj);
        var deserialized = XtiSerializer.Deserialize <TimeObject>(serialized);

        Assert.That(deserialized.Time, Is.EqualTo(new Time(15, 45)));
    }
Esempio n. 11
0
        /** 转换成m:s */
        static TimeObject ToMS(int time)
        {
            TimeObject obj = new TimeObject();
            int        m   = Mathf.FloorToInt(time / 60);
            int        s   = time - m * 60;

            obj.m = m;
            obj.s = s;
            return(obj);
        }
Esempio n. 12
0
        /** 转换成mm:ss */
        public static string ToMMSS(int time)
        {
            TimeObject obj = ToHMS(time);

            if (obj.h > 0)
            {
                return(StringUtils.FillStr(obj.h, 2) + ":" + StringUtils.FillStr(obj.m, 2) + ":" + StringUtils.FillStr(obj.s, 2));
            }
            return(StringUtils.FillStr(obj.m, 2) + ":" + StringUtils.FillStr(obj.s, 2));
        }
Esempio n. 13
0
 public AuctionItem()
 {
     ItemID     = 0;
     Stack      = 0;
     Seller     = 0;
     SellerName = "AuctionMoogle";
     Date       = TimeObject.Convert();
     Price      = 0;
     Sale       = 0;
     SaleDate   = TimeObject.Convert();
 }
Esempio n. 14
0
 private void DoTemperatureCalculations(TimeObject timeObject)
 {
     foreach (var t in _temperatureControlList)
     {
         t.Update(timeObject);
     }
     foreach (var t in _temperatureControlList)
     {
         t.DoPostUpdate(timeObject);
     }
 }
Esempio n. 15
0
        /** 转换成h:m:s */
        static TimeObject ToHMS(int time)
        {
            TimeObject obj = new TimeObject();
            int        h   = Mathf.FloorToInt(time / 3600);
            int        m   = Mathf.FloorToInt((time - h * 3600) / 60);
            int        s   = time - h * 3600 - m * 60;

            obj.h = h;
            obj.m = m;
            obj.s = s;
            return(obj);
        }
Esempio n. 16
0
        private void CloudUpdate(TimeObject timeObject)
        {
            List <cCloud> newList = new List <cCloud>(_cloudList.Count);

            foreach (var c in _cloudList)
            {
                c.Update(timeObject);
                if (c.IsRaining)
                {
                    int range = (int)(c.GetCloudSize());
                    for (int i = -range; i != range; ++i)
                    {
                        for (int j = -range; j != range; ++j)
                        {
                            if (i * i + j * j <= range * range)
                            {
                                if (RandomGenerator.Random.NextDouble() <= 0.85)
                                {
                                    Vector2i newPos = c.PositionInTiles + new Vector2i(i, j);

                                    GetTileOnPosition(newPos).GetTileProperties().SummedUpWater += _worldProperties.RainWaterAmount * timeObject.ElapsedGameTime;
                                    c.ReduceWaterAmount(_worldProperties.RainWaterAmount * timeObject.ElapsedGameTime);
                                }
                            }
                        }
                    }
                }

                if (!c.IsDead())
                {
                    newList.Add(c);
                }
            }
            _cloudList = newList;

            float numberOfTilesToCheck = GetWorldProperties().WorldSizeInTiles.X *GetWorldProperties().WorldSizeInTiles.Y * 0.005f;

            for (int i = 0; i <= numberOfTilesToCheck; i++)
            {
                int id = RandomGenerator.Random.Next(_tileList.Count);
                if (_tileList[id].GetTileType() == eTileType.TILETYPE_WATER)
                {
                    if (_tileList[id].GetTileProperties().TemperatureInKelvin > GetWorldProperties().DesertGrassTransitionAtHeightZero)
                    {
                        if (RandomGenerator.Random.NextDouble() <= 0.01)
                        {
                            cCloud newCloud = new cCloud(this, _tileList[id].GetPositionInTiles());
                            _cloudList.Add(newCloud);
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        private void OnDestroy()
        {
            if (_timeObject != null)
            {
                _timeObject.OnTimeUpdateHandler -= TimeUpdate;
                _timeObject = null;
            }

            _onForwardHandlerCache  = delegate { };
            _onBackwardHandlerCache = delegate { };
            _onPauseHandlerCache    = delegate { };
        }
Esempio n. 18
0
    private void OnTriggerEnter(Collider other)
    {
        if (GameManager.instance.state == GameState.CARD_SELECT)
        {
            StartDeath();
        }
        TimeObject to = other.GetComponent <TimeObject>();

        if (to != null)
        {
            to.Kill(GameManager.time);
        }
    }
    public override void OnInspectorGUI()
    {
        TimeObject to = (TimeObject)target;

        if (to.CustomEditor)
        {
            CreateCustomGUI(to);
        }
        else
        {
            DrawDefaultInspector();
        }
    }
Esempio n. 20
0
        public void Update(TimeObject timeObject)
        {
            _totalTime += timeObject.ElapsedGameTime;
            IsRaining   = (Math.Sin(_rainOffset + _rainFrequency * _totalTime) > 0);

            _absolutePosition += _moveVector * _moveSpeed * timeObject.ElapsedGameTime * 2.0f;

            _moveTimer -= timeObject.ElapsedGameTime;
            if (_moveTimer <= 0)
            {
                _moveTimer = _moveTimerMax;
                _moveSpeed = GetMoveSpeedOnTileProperties(_world.GetTileOnPosition(PositionInTiles).GetTileProperties());
            }
        }
Esempio n. 21
0
    // Use this for initialization
    void Start()
    {
        transform.position  = start_position;
        forwards_direction  = Vector3.Normalize(end_position - start_position);
        backwards_direction = Vector3.Normalize(start_position - end_position);
        current_direction   = forwards_direction;
        transform.rotation  = Quaternion.LookRotation(current_direction);

        distance           = Vector3.Distance(start_position, end_position);
        distance_travelled = 0;

        timeObj  = GetComponent <TimeObject> ();
        gameOver = false;
    }
Esempio n. 22
0
    public void Deactivate(Camera playerCam)
    {
        RaycastHit hit;

        if (Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out hit))
        {
            TimeObject tempTO = hit.collider.gameObject.GetComponent <TimeObject>();
            if (tempTO)
            {
                tempTO.bOnLocalTime   = false;
                tempTO.localTimeScale = 0f;
            }
        }
    }
Esempio n. 23
0
 public void Action(Player Player, string[] cmd)
 {
     switch (cmd[0])
     {
         case MsgC.SetBomb:
             TimeObject t = new TimeObject(Player, new string[] { MsgS.Bomb, cmd[1], cmd[2] }, Setting.Map.BombDelay);
             Timer.Queue.Enqueue(t);
             Player.Map.SendToAll(MsgS.SetBomb + "|" + cmd[1] + "|" + cmd[2]);
             break;
         case MsgC.Bomb:
             Player.Map.SendToAll(MsgS.Bomb + "|" + cmd[1] + "|" + cmd[2]);
             break;
     }
 }
Esempio n. 24
0
        private void Awake()
        {
            _timeObject = new TimeObject();
            _timeObject.OnTimeUpdateHandler += TimeUpdate;
            _timeObject.OnForwardHandler    += _onForwardHandlerCache;
            _timeObject.OnBackwardHandler   += _onBackwardHandlerCache;
            _timeObject.OnPauseHandler      += _onPauseHandlerCache;

            _onForwardHandlerCache  = delegate { };
            _onBackwardHandlerCache = delegate { };
            _onPauseHandlerCache    = delegate { };

            TimeScale = _timeScale;
        }
Esempio n. 25
0
        /// <summary>
        /// Update The Effect if it is Active And call DoUpdate
        /// </summary>
        /// <param name="timeObject"></param>
        public void Update(TimeObject timeObject)
        {
            if (IsEffectActive)
            {
                EffectRemainingTime -= timeObject.ElapsedGameTime;
                _inverseFrequency   -= timeObject.ElapsedGameTime;

                DoUpdate(timeObject);
                if (EffectRemainingTime <= 0.0f)
                {
                    StopEffect();
                }
            }
        }
Esempio n. 26
0
        public override void Update(TimeObject timeObject)
        {
            base.Update(timeObject);

            if (Input.justPressed[Keyboard.Key.Return])
            {
                if (!exiting)
                {
                    StatePlay state = new StatePlay();
                    JamUtilities.Tweens.ShapeAlphaTween.createAlphaTween(_overlay, 255, 0.5f, () => Game.SwitchState(state));
                    exiting = true;
                }
            }
        }
Esempio n. 27
0
 private void DoPlantGrowth(TimeObject timeObject)
 {
     if (GetTileType() == eTileType.TILETYPE_GRASS)
     {
         if (GetTileProperties().SummedUpWater >= GetWorldProperties().PlantGrowthWaterAmount)
         {
             GetTileProperties().SummedUpWater -= GetWorldProperties().PlantGrowthWaterAmount;
             GetTileProperties().ChangeFoodAmountOnTile(eFoodType.FOOD_TYPE_PLANT, _world.GetWorldProperties().PlantGrowthRate);
         }
     }
     else if (GetTileType() == eTileType.TILETYPE_DESERT || GetTileType() == eTileType.TILETYPE_ICE || GetTileType() == eTileType.TILETYPE_SNOW || GetTileType() == eTileType.TILETYPE_WATER)
     {
         GetTileProperties().ChangeFoodAmountOnTile(eFoodType.FOOD_TYPE_PLANT, -_world.GetWorldProperties().PlantGrowthRate *timeObject.ElapsedGameTime);
     }
 }
Esempio n. 28
0
        public void Update(TimeObject timeObject)
        {
            //Console.WriteLine(_inputWallTime);
            if (_inputWallTime > 0)
            {
                _inputWallTime -= timeObject.ElapsedRealTime;
            }

            foreach (cTile t in _tileList)
            {
                t.Update(timeObject);
            }

            CloudUpdate(timeObject);
        }
Esempio n. 29
0
        private void TimerTask(object StateObj)
        {
            TimeObject State = (TimeObject)StateObj;

            Interlocked.Increment(ref State.count);

            //exec
            Program.CommandsExec();

            if (!State.enable)
            {
                State.timer.Dispose();
                //Console.WriteLine("Done  " + DateTime.Now.ToString());
            }
        }
Esempio n. 30
0
        public static TimeObject TimeObject(Rect rect, GUIContent label, TimeObject value)
        {
            rect = EditorGUI.PrefixLabel(rect, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label));

            Dictionary <string, Rect> rects = AdvancedRect.GetRects(rect, AdvancedRect.Orientation.Horizontal,
                                                                    new AdvancedRect.ExpandedItem("Value"),
                                                                    new AdvancedRect.FixedSpace(2),
                                                                    new AdvancedRect.FixedItem("Type", 75)
                                                                    );

            value.value = EditorGUI.DoubleField(rects["Value"], value.value);
            value.type  = (TimeObjectType)EditorGUI.EnumPopup(rects["Type"], value.type);

            return(value);
        }
Esempio n. 31
0
    public void Activate(Camera playerCam)
    {
        RaycastHit hit;

        if (Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out hit))
        {
            TimeObject tempTO = hit.collider.gameObject.GetComponent <TimeObject>();
            if (tempTO)
            {
                currentTarget = tempTO;
                currentTarget.bOnLocalTime   = true;
                currentTarget.localTimeScale = 0f;
            }
        }
    }
    private void GetObjectToActivate()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, maxActivateDistance))
        {
            Debug.Log("Hit: " + hit.transform.name);

            objectToActivate = hit.transform.GetComponent <IActivatable>();
            objectToFreeze   = hit.transform.GetComponent <TimeObject>();
        }
        else
        {
            objectToActivate = null;
            objectToFreeze   = null;
        }
    }