Exemple #1
0
        public virtual void Roam()
        {
            LookDirection = new TGCVector3(LookDirection.X, 0, LookDirection.Z);  // Elimino la componente Y para que roamee al nivel que esta del agua

            timeSinceLastDirection += GameInstance.ElapsedTime;

            TGCVector3 rotationVector = TGCVector3.Empty;

            if (timeSinceLastDirection > timeToChangeDirection)
            {
                timeSinceLastDirection = 0f;
                timeToChangeDirection  = MathExtended.GetRandomNumberBetween(2, 5);

                float randomX = MathExtended.GetRandomNumberBetween(-100, 100);
                float randomZ = MathExtended.GetRandomNumberBetween(-100, 100);

                TGCVector3 lastDirection = LookDirection;
                LookDirection = TGCVector3.Normalize(new TGCVector3(randomX, LookDirection.Y, randomZ));

                float angle = MathExtended.AngleBetween(new TGCVector2(lastDirection.X, lastDirection.Z), new TGCVector2(LookDirection.X, LookDirection.Z));

                rotationVector.Y = -angle;
            }

            rotation += rotationVector;
            Position += LookDirection * roamingSpeed * GameInstance.ElapsedTime;

            TGCMatrix rot   = TGCMatrix.RotationY(rotation.Y);
            TGCMatrix trans = TGCMatrix.Translation(Position);
            TGCMatrix scal  = TGCMatrix.Scaling(scale);

            Transform = scal * rot * trans;
        }
Exemple #2
0
        public Fish(Subnautica gameInstance, string name, List <TgcMesh> meshes, TGCVector3 spawnLocation) : base(gameInstance, name, meshes, 10, 50f)
        {
            CollisionStatus = Utils.ECollisionStatus.NOT_COLLISIONABLE;
            Position        = spawnLocation;
            size            = MathExtended.GetRandomNumberBetween(3, 20);
            scale           = TGCVector3.One * size;

            // LIVING_NPC

            dropsProbability[ItemDatabase.Instance.Generate(EItemID.RAW_FISH)]   = 100;
            dropsProbability[ItemDatabase.Instance.Generate(EItemID.FISH_SCALE)] = 50;
        }
        private void UpdateParticleEmitter()
        {
            timeSinceLastBubblesReposition += ElapsedTime;

            if (timeSinceLastBubblesReposition >= bubblesRepositionCooldown)
            {
                int relativeXPosition = MathExtended.GetRandomNumberBetween(-600, 600);
                int relativeYPosition = MathExtended.GetRandomNumberBetween(-100, 300);
                int relativeZPosition = MathExtended.GetRandomNumberBetween(700, 2000);

                TGCVector3 particlesRelativePosition = Player.RelativeRightDirection * relativeXPosition + Player.RelativeUpDirection * relativeYPosition + Player.LookDirection * relativeZPosition;
                bubbleParticleEmitter.Position = Player.Position + particlesRelativePosition;

                timeSinceLastBubblesReposition = 0f;
            }
        }
        public override void Interact(Player interactor)
        {
            AddHealth(-1 * interactor.AttackDamage);

            GameInstance.OnHitNpcSounds[MathExtended.GetRandomNumberBetween(0, GameInstance.OnHitNpcSounds.Count)].play();

            if (!IsAlive)
            {
                foreach (Item item in dropsProbability.Keys)
                {
                    if (dropsProbability[item] > MathExtended.GetRandomNumberBetween(0, 100))
                    {
                        interactor.CollectItem(item);
                    }
                }

                Destroy();
            }
        }