Update() public method

public Update ( ) : void
return void
Ejemplo n.º 1
0
        /************************/
        /*** Public Functions ***/
        /************************/

        public void Update(float deltaTime)
        {
            if (behavior != null)
            {
                behavior.Update(deltaTime, transform);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the Tank's position if it's not "close enough" to
        /// it's destination
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // If we have any waypoints, the first one on the list is where
            // we want to go
            if (waypoints.Count > 0)
            {
                if (AtDestination)
                {
                    // If we’re at the destination and there is at least one
                    // waypoint in the list, get rid of the first one since we’re
                    // there now
                    waypoints.Dequeue();
                }
                else
                {
                    // If we’re not at the destination, call Update on our
                    // behavior and then move
                    if (currentBehavior != null)
                    {
                        currentBehavior.Update(gameTime);
                    }
                    location = location + (Direction *
                                           MoveSpeed * elapsedTime);
                }
            }
        }
Ejemplo n.º 3
0
    // Update is called once per frame
    public void Update(float deltaTime)
    {
        if (!isNeutral)
        {
            foreach (var b in bases)
            {
                b.Update(deltaTime);
            }
            foreach (var unit in units)
            {
                unit.Update(deltaTime);
            }

            Dictionary <BasePiece, int> attackedBases = BehaviorUtility.AttackedBases(this, GameManager.manager.GetOpponents(this));

            foreach (int value in attackedBases.Values)
            {
                Debug.Log("Being attacked by " + value + " units!");
            }
        }

        if (!isHuman && !isNeutral)
        {
            behavior.Update();
        }
    }
Ejemplo n.º 4
0
        protected override void OnUpdate(TimeSpan time)
        {
            base.OnUpdate(time);

            Behavior.Update(time);
            _threatManager.Update();

            AI.Update(time);
        }
Ejemplo n.º 5
0
        public Bullet Update(int id, List <int> bulletsToDelete)
        {
            if (_dieing)
            {
                UpdateAnimation();
                if (_animations[_currentAnimation].FinishedPlaying)
                {
                    SetInactive(_id);
                    bulletsToDelete.Add(id);
                }

                return(this);
            }

            --KillTime;
            if (KillTime == 0)
            {
                Clear();
                return(this);
            }

            if (SpawnDelay > 0)
            {
                --SpawnDelay;
            }
            if (SpawnDelay != 0)
            {
                return(this);
            }

            UpdateAnimation();
            Behavior.Update(ref this);

            if (AutomaticCollision)
            {
                if (!_tileMap.CellIsPassableByPixel(CircleCollisionCenter) ||
                    !Camera.WorldRectangle.Contains((int)Position.X, (int)Position.Y))
                {
                    Clear();
                    return(this);
                }
            }

            if (CollisionCircle.Intersects(((Player)VariableProvider.CurrentPlayer).PlayerBulletCollisionCircle))
            {
                Clear();
                return(this);
                //VariableProvider.CurrentPlayer.Send<string>("KILL", null);
            }

            _directionVector.Normalize();
            _lastDirection = Direction;
            _lastPosition  = Position;
            return(this);
        }
Ejemplo n.º 6
0
 public void Update(float dt)
 {
     if (_behavior != null)
     {
         base._ = (int)_behavior.Update(dt);
         if (_behavior.IsComplete())
         {
             _behavior = null;
         }
     }
 }
 /// <summary>
 /// helper that gets the TaskStatus of either a Conditional or a ConditionalDecorator
 /// </summary>
 /// <returns>The conditional node.</returns>
 /// <param name="context">Context.</param>
 /// <param name="node">Node.</param>
 private static TaskStatus UpdateConditionalNode(T context, Behavior <T> node)
 {
     if (node is ConditionalDecorator <T> )
     {
         return((node as ConditionalDecorator <T>).ExecuteConditional(context, true));
     }
     else
     {
         return(node.Update(context));
     }
 }
Ejemplo n.º 8
0
        internal override void Update(GameTime gameTime)
        {
            if (IsAlive)
            {
                base.Update(gameTime);
                Behavior?.Update(this, gameTime);

                var distToBoss = Vector2.Distance(game.MainScene.Leviathan.Phy.Pos, Phy.Pos);
                if (distToBoss > 5000)
                {
                    Die(true);
                }
            }
        }
 internal override void Update(GameTime gameTime)
 {
     if (IsAlive)
     {
         base.Update(gameTime);
         if (Behavior != null)
         {
             Behavior.LeviathanSpeedFactor = IsFleeing ? 0.5f : 0.05f;
         }
         Behavior?.Update(this, gameTime);
         SpawnEnemies(gameTime);
     }
     else
     {
         astronaut.Update(gameTime);
         astronatZoom += zoomSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
         var up = ((float)gameTime.TotalGameTime.TotalSeconds % 4) / 4;
         astronautRotation = MathHelper.TwoPi * up;
     }
 }
Ejemplo n.º 10
0
        private void UpdateWiimoteChanged(WiimoteChangedEventArgs args)
        {
            var ws = args.WiimoteState;

            m_debugInfo.Update(ws);

            if (m_isRunning)
            {
                // Profileに設定されている動作を実行
                foreach (WiimoteModel item in m_selectedProfile.ActionAssignments.Keys)
                {
                    foreach (var action in m_selectedProfile.ActionAssignments[item])
                    {
                        if (item.isButton())
                        {
                            ProcessButtonAction(action, item.GetButtonState(ws), item.GetButtonState(prevState));
                        }
                        else
                        {
                            var value     = item.GetAxisValue(ws);
                            var prevValue = item.GetAxisValue(prevState);
                            if (value.Available && prevValue.Available)
                            {
                                ProcessAxisAction(action, value.Value, prevValue.Value);
                            }
                        }
                    }
                }

                // Behavior固有の処理を実行
                m_behavior.Update(ws, prevState);
            }

            // 状態を保持
            prevState = DeepCopy(ws);
        }
Ejemplo n.º 11
0
 static void OnArgumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Behavior.Update(d);
 }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()
    {
        if (!GetReady())
        {
            return;
        }

        Behavior behavior = null;

        if (_behaviors.Count < MAX_BEHAVIORS)
        {
            foreach (UnitCommand cmd in _commands)
            {
                if (_behaviors.Count > 0)
                {
                    behavior = _behaviors.Peek();
                    if (behavior.IsForced() && !cmd._forced)
                    {
                        continue;
                    }
                }

                if (ProcessCommand(cmd))
                {
                    _commands.Erase(cmd);
                    break;
                }
                else
                {
                    _commands.Erase(cmd);
                    continue;
                }
            }
        }

        if (_behaviors.Count > 0)
        {
            behavior = _behaviors.Peek();

            if (behavior.GetBrain() != this)
            {
                Debug.LogWarning("Behavior's unit does not match it's owner's unit");
            }
            if (behavior.GetSelf() != _unit)
            {
                Debug.LogWarning("Behavior's unit does not match brain's unit, the behavior will try to control a different unit");
            }

            if (behavior.Validate())
            {
                if ((behavior.GetFlags() & Behavior.BSR_NEW) != 0)
                {
                    behavior.BeginBehavior();
                }
                else
                {
                    behavior.Update();
                }
            }

            if (behavior.IsEnd())
            {
                behavior.EndBehavior();

                //这里根据toll判断是否可以被打断
                bool nonInterupting = false;

                _behaviors.Dequeue();

                //reset next behavior
                if (_behaviors.Count > 0 && _behaviors.Peek().ShouldReset() && !nonInterupting)
                {
                    _behaviors.Peek().Reset();
                }
            }
        }

        bool isProcessed = false;

        for (int i = 0; i < (int)EActionStateIDs.ASID_COUNT; ++i)
        {
            if (_actionStates[i].IsActive())
            {
                if (!_actionStates[i].ContinueStateAction())
                {
                    _actionStates[i].EndState(3);
                }
                else
                {
                    isProcessed = true;
                }
            }
        }
        if (isProcessed == false)
        {
            UnpauseNextActionState();
        }
    }