Пример #1
0
    private void MovementUpdater()
    {
        if (!m_canMove || m_isDead)
        {
            return;
        }

        Vector3 targetPosition = m_playerEntity.GetCurrentPosition().WorldPosition;

        if (Vector3.Distance(transform.position, targetPosition) > 2 && !m_isDashing)
        {
            // Teleport to loop node position
            transform.position = targetPosition;

            // Play teleport sfx
            AudioManager.PlaySound("teleport", 0.5f, false);
        }
        else
        {
            // Normal movement to target node
            transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * m_movementSpeed);
        }

        if (m_updatePositionCooler > 0)
        {
            m_updatePositionCooler -= Time.deltaTime;
        }
        else
        {
            m_playerEntity.Move();
            m_updatePositionCooler = (1f / m_movementSpeed);
        }
    }
Пример #2
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            // TODO: randomize chance, and only on ice or snow ?
            // check is block below is snow
            Vector3 dir = Vectors.Float.Randomize(Zombiome.rand, 1f);

            dir   = dir.normalized;
            dir.y = 0.1f;
            Vector3i at = Vectors.ToInt(target.GetPosition());

            if (World.GetBlock(at).type == BlockValue.Air.type && World.GetBlock(at - Vectors.Up).type == BlockValue.Air.type)
            {
                yield break; // target is not on ground  // todo: snow only
            }
            Vector3 motion = EffectsEntity.MoveDir(target);

            if (motion.magnitude <= 0.3f)
            {
                yield break;
            }
            Vector3 slideDir = Vectors.Float.Randomize(rand, 1f, motion.normalized).normalized;

            slideDir.y = 0.05f;
            EntityMover mover = new EntityMover(2, 0.2f, 1); // .Config(1);

            yield return(mover.Move(target, slideDir));

            target.Buffs.AddBuff("buffRagdoll");
            if (target is EntityPlayerLocal)
            {
                GameManager.ShowTooltip((EntityPlayerLocal)target, "You slipped !");
            }
        }
Пример #3
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            if (target.Buffs.HasBuff(buff))
            {
                yield break;
            }
            Vector3     dir   = -0.5f * Vectors.Float.UnitY;
            EntityMover mover = new EntityMover(1); // .Config(1);

            yield return(mover.Move(target, dir));

            target.Buffs.AddBuff(buff);
        }
Пример #4
0
        public override IEnumerator Apply(EntityPlayer player, EntityAlive target, OptionEffect opt)
        {
            Vector3 tpos = target.GetPosition();
            Vector3 s    = Geo3D.Surface(tpos);

            if (s.y <= 1)
            {
                yield break;
            }
            float dy = tpos.y - s.y;

            if (dy >= 0.5f)
            {
                yield break;
            }
            if (dy <= -0.5f)
            {
                yield break;
            }
            Vector3     dir   = -0.3f * Vectors.Float.UnitY;
            EntityMover mover = new EntityMover(1); // .Config(1);

            yield return(mover.Move(target, dir));
        }
Пример #5
0
        // private int cursor = -1;
        public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt)
        {
            Vector3 ppos = player.GetPosition();

            Vector3 where = place.position;
            Bounds area = new Bounds(ppos, new Vector3(40, 40, 40));

            EntityPool.Update(area);

            Vector3 sharedDir = place.direction;

            sharedDir.y = 0.2f;                           // Math.Abs(sharedDir.y); // TODO: constraint in Directions
            EntityMover mover = new EntityMover(3, 0.3f); // .Config(1);
            int         mode  = 0;                        // 0nothing, 1random, 2parralel, 3 player
            float       u     = rand.RandomFloat;

            if (u < 0.4f)
            {
                mode = 3;
            }
            else if (u < 0.6f)
            {
                mode = 2;
            }
            else if (u < 0.8f)
            {
                mode = 1;
            }

            foreach (Entity entity in EntityPool.Entities)
            {
                if (entity == null)
                {
                    continue;
                }
                // if (entity.IsDead()) continue;
                EntityAlive alive = (EntityAlive)entity;
                if (!alive.Buffs.HasBuff(opt.OptionEntity.buff))
                {
                    Printer.Log(40, "MovingGhost buffing", opt.OptionEntity.buff, alive);
                    alive.Buffs.AddBuff(opt.OptionEntity.buff);
                }
                Vector3 toward = Vectors.Float.Zero;
                if (false)
                {
                    if (mode == 3)
                    {
                        toward = (ppos - alive.GetPosition()).normalized;
                        // toward.y = rand.RandomRange(0.05f, 0.2f);
                        toward.y = 0.2f;
                    }
                    else if (u < 0.6)
                    {
                        toward = sharedDir;
                    }
                    else if (u < 0.8)
                    {
                        toward.x = rand.RandomRange(-1f, 1f);
                        toward.z = rand.RandomRange(-1f, 1f);
                        // toward.y = rand.RandomRange(0.05f, 0.2f);
                        toward   = toward.normalized;
                        toward.y = 0.2f;
                    }
                }
                toward = (ppos - alive.GetPosition()).normalized;
                // toward.y = rand.RandomRange(0.05f, 0.2f);
                toward.y = 0.2f;
                if (toward.magnitude > 0)
                {
                    // Can we have a single routine that manages all motions ?
                    Printer.Log(40, "MovingGhost motion", entity, toward);
                    Zombiome.Routines.Start(mover.Move(alive, toward), "MovingGhost");
                }
            }
        }