예제 #1
0
    //attacked
    public void Shot()
    {
        //dec
        health--;

        //feedback
        StartCoroutine(Flash());

        //check to see if dead
        if (health <= 0)
        {
            //call
            Dead();

            //done
            return;
        }

        //chance to become enraged
        int chance = Random.Range(1, 100);

        //check
        if (chance > 80 && !runner)
        {
            //remove walk
            Destroy(GetComponent <MovementBehavior>());

            //set movement to run
            MovementBehavior = gameObject.AddComponent <MovementRun>();
        }
    }
예제 #2
0
 public MovementInput(MonoBehaviour root, JumpBehavior jump, MovementBehavior move, string horzName = DEFAULT_HORZ_AXIS_NAME, string vertName = DEFAULT_VERT_AXIS_NAME)
 {
     rootObject        = root;
     controller        = root.GetComponent <CharacterController>();
     horzInputAxisName = horzName;
     vertInputAxisName = vertName;
 }
        private static void OnStartMoving(ContextActor actor, MovementBehavior movement)
        {
            if (!AllowComparer)
            {
                return;
            }

            var bot = BotManager.Instance.GetCurrentBot();

            Task.Factory.StartNew(
                () =>
            {
                var element = movement.TimedPath.GetCurrentElement();

                bot.Character.HighlightCell(element.CurrentCell, Color.Green);

                while (!movement.IsEnded())
                {
                    var newElement = movement.TimedPath.GetCurrentElement();

                    if (element != newElement)
                    {
                        element = newElement;

                        bot.Character.ResetCellsHighlight();
                        bot.Character.HighlightCell(element.CurrentCell, Color.Green);
                    }

                    Thread.Sleep(30);
                }
            });
        }
예제 #4
0
 private void Start()
 {
     movement   = GetComponent <MovementBehavior>();
     attack     = GetComponent <AttackBehavior>();
     player     = GetComponent <WizardBehavior>();
     playerAnim = GetComponentInChildren <AnimationBehavior>();
 }
예제 #5
0
 public virtual void Tick(RealmTime time)
 {
     if (this is Projectile)
     {
         return;
     }
     if (interactive && Owner != null)
     {
         if (!HasConditionEffect(ConditionEffects.Stasis))
         {
             MovementBehavior.Tick(this, time);
             AttackBehavior.Tick(this, time);
             ReproduceBehavior.Tick(this, time);
         }
         foreach (var i in CondBehaviors)
         {
             if ((i.Condition & BehaviorCondition.Other) != 0 &&
                 i.ConditionMeet(this))
             {
                 i.Behave(BehaviorCondition.Other, this, time, null);
             }
         }
         posHistory[posIdx++] = new Position {
             X = X, Y = Y
         };
         ProcessConditionEffects(time);
     }
 }
예제 #6
0
        public void NewPath(Entity owner, MovementBehavior movement, List <LayerTile> path, bool recalculate)
        {
            if (!recalculate)
            {
                movement.SetPath(path);

                //We synchro the path for other to visualize it
                var message = networkService.CreateServerMessage();

                message.Write(MOVE);

                message.Write(owner.Name);
                //if the path was accepted, we will send it
                path = movement.path;
                message.Write(path.Count);

                foreach (LayerTile tile in path)
                {
                    message.Write(tile.X);
                    message.Write(tile.Y);
                    Trace.WriteLine("X: " + tile.X + ", Y:" + tile.Y);
                }
                networkService.SendToClients(message, DeliveryMethod.ReliableOrdered);
            }
            else
            {
                movement.ForcePath(path);
            }
        }
예제 #7
0
 public void SetDefaults()
 {
     m_MovementBehavior        = MovementBehavior.FollowAlways;
     m_PaintHeightmap          = true;
     m_PaintAlphamap           = true;
     m_StampingOffsetFromClone = 0.0f;
 }
예제 #8
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();

            // draw button-like toggles for choosing which terrain textures to sample
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label(Styles.cloneSourceContent);

                if (GUILayout.Button(Styles.cloneTextureContent, Styles.GetButtonToggleStyle(m_PaintAlphamap)))
                {
                    m_PaintAlphamap = !m_PaintAlphamap;
                }

                if (GUILayout.Button(Styles.cloneHeightmapContent, Styles.GetButtonToggleStyle(m_PaintHeightmap)))
                {
                    m_PaintHeightmap = !m_PaintHeightmap;
                }
            }
            EditorGUILayout.EndHorizontal();

            m_MovementBehavior        = (MovementBehavior)EditorGUILayout.EnumPopup(Styles.cloneBehaviorContent, m_MovementBehavior);
            m_StampingOffsetFromClone = EditorGUILayout.Slider(Styles.heightOffsetContent, m_StampingOffsetFromClone,
                                                               -terrain.terrainData.size.y, terrain.terrainData.size.y);

            editContext.ShowBrushesGUI(0);

            if (EditorGUI.EndChangeCheck())
            {
                m_isPainting        = false;
                m_HasDoneFirstPaint = false;
                Save(true);
            }
        }
예제 #9
0
    void Awake()
    {
        _playerShip = GameObject.FindWithTag("PlayerShip").GetComponent<Ship>();
        _playerShipMovementBehavior = _playerShip.GetComponent<MovementBehavior>();

        var init = CooldownManager.Instance;
    }
예제 #10
0
 void Start()
 {
     _move = GetComponent <MovementBehavior>();
     _playerInputs.Player.Movement.performed += context => _move.Movement((int)context.ReadValue <float>());
     _skip = GetComponent <MovementBehavior>();
     _playerInputs.PlayerSkip.SkipMovement.performed += context => _skip.MovementSkipping((int)context.ReadValue <float>());
 }
예제 #11
0
        private void SynchroPath(object sender, IncomingMessage receivedMessage)
        {
            Entity owner = networkedScene.EntityManager.Find(receivedMessage.ReadString());

            if (owner != null && !owner.IsDisposed)
            {
                int pathLength            = receivedMessage.ReadInt32();
                MovementBehavior movement = owner.FindComponent <MovementBehavior>();

                if (movement != null)
                {
                    List <LayerTile> path = new List <LayerTile>(pathLength);

                    Map map = Map.map;
                    for (int i = 0; i < pathLength; i++)
                    {
                        LayerTile tile = map.GetTileByMapCoordinates(receivedMessage.ReadInt32(), receivedMessage.ReadInt32());
                        if (tile != null)
                        {
                            path.Add(tile);
                        }
                    }
                    movement.SetPathForClient(path);
                }
            }
        }
예제 #12
0
    public void Start()
    {
        // Checking if all referencies are working
        if (movement == null)
        {
            movement = gameObject.GetComponent <MovementBehavior>();
        }
        if (movement == null)
        {
            movement = gameObject.AddComponent <MovementBehavior>();
        }
        if (movement.enemyBehavior == null)
        {
            movement.enemyBehavior = this;
        }

        // Getting a personnal healthbar
        healthBar = GameManager.instance.healthBarManager.GetBar();
        healthBar.Show();

        // Parsing values to the enemy
        visual = Instantiate(param.model, transform.position, Quaternion.identity, transform);

        // Checking if the enemy visual has a visualBehavior
        enemyVisualBehavior = visual.GetComponent <EnemyVisualBehavior>();
        if (enemyVisualBehavior != null)
        {
            enemyVisualBehavior.enemyBehavior = this;
        }

        health         = param.health;
        movement.speed = param.speed;
    }
예제 #13
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     baseMovement = animator.GetBehaviour <MovementBehavior>();
     animator.transform.GetComponent <tk2dSpriteAnimator>().Play("跑步");
     animator.SetBool("跑动", true);
     //设置速度
     baseMovement.currentSpeed = baseMovement.RunSpeed;
 }
예제 #14
0
    public static SetMovementRate(Mob m, float movementrate)
    {
        MovementBehavior b = m.Get < MovementBehavior();

        if (b != null)
        {
            b.SetMovementRate(1.20f);
        }
    }
예제 #15
0
    //bool facingRight;

    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        playerTrans = animator.transform.parent;
        rig         = playerTrans.GetComponent <Rigidbody2D>();
        baseMove    = animator.GetBehaviour <MovementBehavior>();
        sprites     = animator.GetComponentsInChildren <tk2dSprite>();
        //facingRight = playerTrans.localScale.x == 1 ? true : false;
        animator.transform.GetComponent <tk2dSpriteAnimator>().Play("跳跃_上升");
    }
예제 #16
0
        public MovingCamera(BoardAbstract testBoard, Graphics2D g2) : base(boardHalfWidth, boardHalfHeight)
        {
            this.gBoard       = g2;
            this.currentBoard = testBoard;
            this.setPos(0, 0);
            behaviorCurrent = new InactiveBehavior();

            init();
        }
예제 #17
0
        public void lockAtCurrentPosition()
        {
            this.translationComposite.halt();

            resetAngle();
            behaviorPaused  = behaviorCurrent;
            behaviorCurrent = new InactiveBehavior();
            lockState       = true;
        }
예제 #18
0
        public override General.Common.IEncodable Decode(General.Encoding.BinaryInput stream)
        {
            base.Decode(stream);
            this.MovementBehavior        = stream.ReadObject <MovementBehavior>();
            this.MovementBehavior.Entity = this;
            this.elapsed      = stream.ReadSingle();
            this.nextMovement = stream.ReadSingle();

            return(this);
        }
예제 #19
0
        /**
         * Use this method for updating old pre-camera methods and for other debugging
         * @param position - Camera.ORIGIN for camera cornered at 0,0 (classic)
         */
        public void lockAtPosition(Point position)
        { //CHANGE TO INT INSTEAD OF FLOAT LATER
            this.x = (int)position.getX();
            this.y = (int)position.getY();

            this.translationComposite.halt();

            behaviorPaused  = behaviorCurrent;
            behaviorCurrent = new InactiveBehavior(); //make inactive behavior static singleton later
            lockState       = true;
        }
예제 #20
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     playerTrans  = animator.transform.parent;
     weaponTrans  = animator.transform.Find("武器");
     weaponSprite = weaponTrans.GetComponent <tk2dSprite>();
     tkAnimator   = animator.transform.GetComponent <tk2dSpriteAnimator>();
     FunctionLock = false;
     time         = 0;
     tkAnimator.Play("前冲攻击");
     baseMovement = animator.GetBehaviour <MovementBehavior>();
     //设置速度
     baseMovement.currentSpeed = baseMovement.WalkSpeed;
 }
예제 #21
0
    void Awake()
    {
        rb             = GetComponent <AIRigidbody>();
        steeringBasics = GetComponent <Steering>();
        sensor         = transform.Find("Sensor").GetComponent <Sensor>();
        mb             = GetComponent <MovementBehavior>();

        //Velocity Match
        facingCosineVal = Mathf.Cos(facingCosine * Mathf.Deg2Rad);

        //Cohesion
        cohFacingCosineVal = Mathf.Cos(cohFacingCosine * Mathf.Deg2Rad);
    }
예제 #22
0
        public virtual bool NotifyStartMoving(Path path)
        {
            if (path.IsEmpty())
            {
                logger.Warn("Try to start moving with an empty path");
                return(false);
            }

            Movement = new MovementBehavior(path, GetAdaptedVelocity(path));
            Movement.Start();


            return(NotifyStartMoving(Movement));
        }
예제 #23
0
        public static void HandleGameMapMovementMessage(Bot bot, GameMapMovementMessage message)
        {
            if (bot.Character == null || bot.Character.Context == null)
            {
                logger.Error("Context is null as processing movement");
                return;
            }

            ContextActor actor      = null;
            bool         fightActor = false;

            if (bot.Character.IsFighting())
            {
                actor = bot.Character.Fight.GetActor(message.actorId);
            }
            if (actor == null)
            {
                actor = bot.Character.Context.GetActor(message.actorId);
            }
            else
            {
                fightActor = true;
            }
            if (actor == null)
            {
                logger.Error("Actor {0} not found (known : {1})", message.actorId, String.Join(",", fightActor ? bot.Character.Fight.Actors : bot.Character.Context.Actors)); // only a log for the moment until context are fully handled
                return;
            }

            // just to update the position. If in fight, better update immediately to be sure that the next action take the mouvement into account
            if (message.keyMovements.Length == 1)
            {
                actor.UpdatePosition(message.keyMovements[0]);
            }
            else
            {
                Path path = Path.BuildFromServerCompressedPath(bot.Character.Map, message.keyMovements);

                if (path.IsEmpty())
                {
                    logger.Warn("Try to start moving with an empty path");
                    return;
                }

                var movement = new MovementBehavior(path, actor.GetAdaptedVelocity(path));
                movement.Start(DateTime.Now + TimeSpan.FromMilliseconds(EstimatedMovementLag));

                actor.NotifyStartMoving(movement);
            }
        }
예제 #24
0
파일: Player.cs 프로젝트: anddonram/CODE3
 private void CalculatePathDStar(WorldObject sel, LayerTile end)
 {
     if (sel != null && !sel.IsDestroyed() && !sel.IsActionBlocking())
     {
         Trace.WriteLine("calculating path");
         MovementBehavior per   = sel.Owner.FindComponent <MovementBehavior>();
         LayerTile        start = map.GetTileByWorldPosition(sel.GetCenteredPosition());
         DStarLite        dstar = sel.Owner.FindComponent <DStarLite>();
         if (dstar != null && per != null)
         {
             List <LayerTile> dPath = dstar.DStar(start, end);
             Trace.WriteLine("path: " + dPath.Count.ToString());
             per.SetPath(dPath);
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        movementBehavior = StaticValues.PlayerShipMovementBehavior;

        //speedEffect_L = GetComponent<ParticleSystem>();
        //speedEffect_R = GetComponent<ParticleSystem>();

        //engineEffect_L = GetComponent<ParticleSystem>();
        //engineEffect_R = GetComponent<ParticleSystem>();

        //movementEffect = GetComponent<ParticleSystem>();

        //speedEffect_L.emission
        //speedEffect_R
        //cruiserMovementEffect.emissionRate = 0;
        //cruiserMovementEffect.startLifetime = baseStartLife;
    }
예제 #26
0
    // Use this for initialization
    void Start()
    {
        healthBar.material = Instantiate(healthBar.material);
        player             = GameManager.Instance.GetPlayerById(playerId);
        wizardTarget       = player.wizardRef;
        wizard             = wizardTarget.GetComponent <WizardBehavior>();
        movement           = wizardTarget.GetComponent <MovementBehavior>();
        playerHead.sprite  = wizard.charData.artwork;
        background.color   = wizard.playerColor;
        playerHealth       = wizard.maxHealth;
        playerStamina      = movement.flyMaxStamina;
        var spellIconsList = spellIcons.GetComponentsInChildren <SpellIcon>();

        foreach (SpellIcon spellIcon in spellIconsList)
        {
            spellIcon.SetInputType(player.inputType);
        }
    }
예제 #27
0
        public virtual bool NotifyStartMoving(MovementBehavior movement)
        {
            Movement = movement;

            if (Movement.StartCell != Position.Cell)
            {
                logger.Warn("Actor start cell incorrect for this moving path Position={0}, StartPath={1}", Position.Cell, Movement.StartCell);
                Position.Cell = Movement.StartCell;
            }

            var handler = StartMoving;

            if (handler != null)
            {
                handler(this, Movement);
            }

            return(true);
        }
예제 #28
0
        public virtual bool NotifyStartMoving(MovementBehavior movement)
        {
            Movement = movement;

            if (Movement.StartCell != Cell)
            {
                logger.Warn("Actor start cell incorrect for this moving path Position={0}, StartPath={1}, Path={2}", Cell, Movement.StartCell, String.Join <World.Cell>(",", Movement.MovementPath.Cells));
                Cell = Movement.StartCell;
            }

            var handler = StartMoving;

            if (handler != null)
            {
                handler(this, Movement);
            }

            return(true);
        }
예제 #29
0
 void Start()
 {
     rig     = GetComponent <Rigidbody2D>();
     anim    = GetComponentInChildren <Animator>();
     sprites = bodyAnimTrans.GetComponentsInChildren <tk2dSprite>();
     //挨打特效动画
     effectRenderer = effectTrans.GetComponent <MeshRenderer>();
     effectAnimator = effectTrans.GetComponent <tk2dSpriteAnimator>();
     effectAnimator.AnimationCompleted = OnEffectAnimationCompleted;
     effectRenderer.enabled            = false;
     //通用特效动画
     commonEffectRenderer = commonEffectTrans.GetComponent <MeshRenderer>();
     commonEffectAnimator = commonEffectTrans.GetComponent <tk2dSpriteAnimator>();
     commonEffectAnimator.AnimationCompleted = OnCommonEffectAnimationCompleted;
     commonEffectRenderer.enabled            = false;
     //身体动画
     bodyAnimator = bodyAnimTrans.GetComponent <tk2dSpriteAnimator>();
     bodyAnimator.AnimationCompleted = OnAnimationCompleted;
     baseMove = anim.GetBehaviour <MovementBehavior>();
 }
예제 #30
0
        private void CalculatePath(MovementBehavior per)
        {
            Trace.WriteLine("calculating path");
            LayerTile start = map.GetTileByWorldPosition(selectedWO.GetCenteredPosition());

            WaveServices.TaskScheduler.CreateTask(async() =>
            {
                List <LayerTile> dPath = AStar.Astar(currentTile, start);
                Trace.WriteLine("path: " + dPath.Count.ToString());
                await WaveServices.Dispatcher.RunOnWaveThread(
                    () =>
                {
                    if (!selectedWO.IsDestroyed() && !selectedWO.IsActionBlocking())
                    {
                        SendPath(dPath);
                    }
                }
                    );
            });
        }
예제 #31
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player" && collision.gameObject != mageOwner && canDamage)
     {
         WizardBehavior   player    = collision.GetComponent <WizardBehavior>();
         MovementBehavior pMovement = player.GetComponent <MovementBehavior>();
         player.TakeDamage(damage, transform.position);
         pMovement.KnockOut(dir, knockbackForce);
         CheckHasEffect(player);
         MakeExplosion();
         canDamage = false;
         Kill();
         SpellShake();
     }
     if (collision.tag == "Spell")
     {
         MakeExplosion();
         Kill();
         collision.GetComponent <Spell>().Kill();
     }
 }
예제 #32
0
        private void Move(object sender, IncomingMessage receivedMessage)
        {
            Entity owner = networkedScene.EntityManager.Find(receivedMessage.ReadString());

            if (owner != null && !owner.IsDisposed)
            {
                bool recalculate = receivedMessage.ReadBoolean();
                int  pathLength  = receivedMessage.ReadInt32();
                Trace.WriteLine("moving tiles:" + pathLength);
                MovementBehavior movement = owner.FindComponent <MovementBehavior>();

                if (movement != null && pathLength > 1)
                {
                    List <LayerTile> path      = new List <LayerTile>(pathLength);
                    bool             validPath = true;
                    Map map = Map.map;
                    //First tile
                    path.Add(map.GetTileByMapCoordinates(receivedMessage.ReadInt32(), receivedMessage.ReadInt32()));
                    for (int i = 1; i < pathLength; i++)
                    {
                        LayerTile tile = map.GetTileByMapCoordinates(receivedMessage.ReadInt32(), receivedMessage.ReadInt32());

                        if (tile != null && !path.Contains(tile) && map.Adjacent(tile, path[i - 1])) //Cuando haya restricciones para pasar por una casilla se deben añadir también aquí
                        {
                            path.Add(tile);
                        }
                        else
                        {
                            validPath = false;
                            break;
                        }
                    }

                    if (validPath)
                    {
                        NewPath(owner, movement, path, recalculate);
                    }
                }
            }
        }