예제 #1
0
        public void Update()
        {
            if (mousePosition == null)
            {
                mousePosition = new ObservedValue <GridPoint2>(gridEvents.MousePosition);
                mousePosition.OnValueChange += PaintHighlight;
            }

            mousePosition.Value = gridEvents.MousePosition;

            if (currentShape == null)
            {
                return;
            }

            if (Input.GetMouseButtonDown(0))
            {
                LeftClick();
            }

            if (Input.GetMouseButtonDown(1))
            {
                RightClick();
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                RotateShape();
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                FlipShape();
            }
        }
예제 #2
0
 // Use this for initialization
 void Awake() {
     gpsObject = this;
     deltaDistance = new ObservedValue<float>(0);
     timeOfLastDistanceUpdate = DateTime.UtcNow.Second;
     state = new ObservedValue<LocationState>(LocationState.Initializing);
     latitude = 0f;
     longitude = 0f;
 }
예제 #3
0
    // Use this for initialization
    void Awake()
    {
        if (numHealthPots == null)
        {
            numHealthPots = new ObservedValue <int>(0);
        }
        else
        {
            numHealthPots = new ObservedValue <int>(numHealthPots.Value);
        }

        if (numCritPots == null)
        {
            numCritPots = new ObservedValue <int>(0);
        }
        else
        {
            numCritPots = new ObservedValue <int>(numCritPots.Value);
        }

        if (numAttackPots == null)
        {
            numAttackPots = new ObservedValue <int>(0);
        }
        else
        {
            numAttackPots = new ObservedValue <int>(numAttackPots.Value);
        }

        healthPot = ItemList.itemMasterList[ItemList.HEALTH_POTION];
        critPot   = ItemList.itemMasterList[ItemList.CRIT_POTION];
        attackPot = ItemList.itemMasterList[ItemList.ATTACK_POTION];

        if (healthPotsText != null)
        {
            healthPotsText.text          = "x" + numHealthPots.Value;
            numHealthPots.OnValueChange += () => {
                healthPotsText.text = "x" + numHealthPots.Value;
            };
        }

        if (critPotsText != null)
        {
            critPotsText.text          = "x" + numCritPots.Value;
            numCritPots.OnValueChange += () => {
                critPotsText.text = "x" + numCritPots.Value;
            };
        }

        if (attackPotsText != null)
        {
            attackPotsText.text          = "x" + numAttackPots.Value;
            numAttackPots.OnValueChange += () => {
                attackPotsText.text = "x" + numAttackPots.Value;
            };
        }
    }
예제 #4
0
파일: Player.cs 프로젝트: Mechware/Go4AWalk
    void Awake()
    {
        if (gold == null)
        {
            gold          = new ObservedValue <int>(0);
            lootGold      = new ObservedValue <int>(0);
            experience    = new ObservedValue <int>(0);
            level         = new ObservedValue <int>(1);
            totalDistance = new ObservedValue <float>(0);
            health        = new ObservedValue <int>(100);
        }
        else
        {
            gold          = new ObservedValue <int>(gold.Value);
            lootGold      = new ObservedValue <int>(lootGold.Value);
            experience    = new ObservedValue <int>(experience.Value);
            level         = new ObservedValue <int>(level.Value);
            totalDistance = new ObservedValue <float>(totalDistance.Value);
            health        = new ObservedValue <int>(health.Value);
        }
        crit           = new ObservedValue <int>(0);
        attackStrength = 5 + level.Value + equippedWeapon.baseAttack;

        if (defenseModifier == 0)
        {
            defenseModifier = 1;
        }
        else
        {
            defenseModifier = equippedArmor.attributeValue;
        }

        maxHealth  = 100 + 10 * level.Value;
        critFactor = 4 + Mathf.RoundToInt((equippedWeapon.critModifier - 1f) * 40);

        loadPlayer();

        if (equippedWeapon.Equals(ItemList.noItem) || equippedWeapon.Equals(default(item)))
        {
            equipWeapon(ItemList.itemMasterList[ItemList.WOOD_SWORD]);
        }

        if (died)
        {
            health.Value = maxHealth / 2;
            lootGold     = new ObservedValue <int>(0);
        }

        if (GameState.atCamp)
        {
            gold.Value    += lootGold.Value;
            lootGold.Value = 0;
        }

        savePlayer();
        instance = this;
    }
예제 #5
0
        private void BaseConstructor(TimeStruct initialTime)
        {
            minuteTimer  = new Clock();
            timeObserver = new ObservedValue <TimeStruct>(initialTime);

            minuteTimer.Reset(60f);
            minuteTimer.OnClockExpired += () => {
                timeObserver.Value += TimeStruct.OneMinute;
                minuteTimer.Reset(60f);
            };
        }
예제 #6
0
        public void Reset()
        {
            foreach (var cell in grid.Cells)
            {
                cell.SetState(true, -1, false);
            }

            gameOverText.gameObject.SetActive(false);
            gameOver = new ObservedValue <bool>(false);
            gameOver.OnValueChange   += () => { gameOverText.gameObject.SetActive(gameOver.Value); };
            linesCount                = new ObservedValue <int>(0);
            linesCount.OnValueChange += () => { linesCountText.text = linesCount.Value.ToString(); };

            AddNewCells();
        }
예제 #7
0
        public override void InitGrid()
        {
            gridEvents = GetComponent <GridEventTrigger>();

            Grid.Apply(c => c.GetComponent <PolyominoCell>().Init());

            puzzleGrid = new PuzzleGrid <Polyominoes.Pentomino.Type>(Grid);

            currentShapeType = Polyominoes.Pentomino.Type.F;
            currentShape     = new ObservedValue <TightShape2>(new TightShape2(Polyominoes.Pentomino.Shapes[currentShapeType]));

            currentShape.OnValueChange += PaintHighlight;
            currentShape.OnValueChange += UpdateCurrentShape;

            UpdateCurrentShape();
        }
예제 #8
0
        public void Reset()
        {
            foreach (var point in Grid.Points)
            {
                dataGrid[point] = false;
                (Grid[point].GetComponent <SpriteCell>()).Color = offColor;
            }

            moveCount = new ObservedValue <int>(0);
            moveCount.OnValueChange += () => { moveCountText.text = moveCount.Value.ToString(); };

            gameOverText.gameObject.SetActive(false);
            gameOver = new ObservedValue <bool>(false);
            gameOver.OnValueChange += () => { gameOverText.gameObject.SetActive(gameOver.Value); };

            CreatePuzzle();
        }
        public WebMetricsAggregateState(string instanceName)
            : base(instanceName)
        {
            _lock = new object();

            TotalObservedTime = new ElapsedTime(ElapsedTime.ElapsedTimeUnitType.Milliseconds);

            TotalObservedRequests = new SumTotal(_lock);

            ResponseBodyLengthMinimum    = new ObservedValue(ObservationType.Minimum);
            ResponseBodyLengthMaximum    = new ObservedValue(ObservationType.Maximum);
            ResponseBodyLengthAverage    = new MeanAverage(TotalObservedRequests, _lock);
            _responseBodyLengthComposite = new CompositeCounter(
                new ICounter <long>[]
            {
                ResponseBodyLengthMinimum,
                ResponseBodyLengthMaximum,
                ResponseBodyLengthAverage
            },
                _lock);

            RequestMillisecondsMinimum    = new ObservedValue(ObservationType.Minimum);
            RequestMillisecondsMaximum    = new ObservedValue(ObservationType.Maximum);
            RequestMillisecondsAverage    = new MeanAverage(TotalObservedRequests, _lock);
            _requestMillisecondsComposite = new CompositeCounter(
                new ICounter <long>[]
            {
                RequestMillisecondsMinimum,
                RequestMillisecondsMaximum,
                RequestMillisecondsAverage
            },
                _lock);

            RequestHandlerMillisecondsMinimum    = new ObservedValue(ObservationType.Minimum);
            RequestHandlerMillisecondsMaximum    = new ObservedValue(ObservationType.Maximum);
            RequestHandlerMillisecondsAverage    = new MeanAverage(TotalObservedRequests, _lock);
            _requestHandlerMillisecondsComposite = new CompositeCounter(
                new ICounter <long>[]
            {
                RequestHandlerMillisecondsMinimum,
                RequestHandlerMillisecondsMaximum,
                RequestHandlerMillisecondsAverage
            },
                _lock);
        }
        public void Start()
        {
            markers = new List <GameObject>();

            observedCurve = new ObservedValue <CurveType>(curve);
            observedCurve.OnValueChange += UpdateCurveType;

            observedMarker = new ObservedValue <MarkerType>(markerType);
            observedMarker.OnValueChange += UpdateMarkers;

            observedColoring = new ObservedValue <ColoringType>(coloringType);
            observedColoring.OnValueChange += Generate;

            pointCount = new ObservedValue <int>(pointMax);
            pointCount.OnValueChange += UpdateCurvePoints;

            UpdateCurveType();
        }
예제 #11
0
 public void Start()
 {
     hp = new ObservedValue <int>(startingHp);
 }
예제 #12
0
 void Start()
 {
     coins = new ObservedValue <int>(0);
     coins.OnValueChange += UpdateUI;
 }