private void OnTriggerExit(Collider other)
 {
     if (other.GetComponent <WaterComponent>())
     {
         waterComponentEntered = null;
     }
 }
Esempio n. 2
0
    public override Behaviour MakeComponent(GameObject gameObject)
    {
        WaterComponent water = gameObject.AddComponent <WaterComponent>();

        water.density = density;
        return(water);
    }
Esempio n. 3
0
 void OnTriggerExit(Collider c)
 {
     if (c == waterCollider)
     {
         water         = null;
         waterCollider = null;
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <WaterComponent>())
     {
         waterComponentEntered = other.GetComponent <WaterComponent>();
         waterLevel            = other.transform.position.y;
         waterTolerance        = GetComponent <SphereCollider>().radius;
     }
 }
Esempio n. 5
0
    public bool TryIrrigate(WaterComponent water)
    {
        if (IsIrrigated)
        {
            return(false);
        }

        Debug.Log("Irrigated!");

        IsIrrigated = true;

        OnIrrigated?.Invoke(water);

        return(true);
    }
Esempio n. 6
0
    void OnTriggerEnter(Collider c)
    {
        WaterComponent cWater = c.GetComponent <WaterComponent>();

        if (cWater == null && c.transform.parent != null)
        {
            cWater = c.transform.parent.GetComponent <WaterComponent>();
        }
        if (cWater != null)
        {
            waterCollider = c;
            if (water != cWater)
            {
                water = cWater;
                float archimedesForceMagnitude = water.density * Mathf.Abs(Physics.gravity.y) * volume;
                localArchimedesForce = new Vector3(0, archimedesForceMagnitude, 0) / voxels.Count;
            }
        }
    }
Esempio n. 7
0
        private void LoadWater()
        {
            var newEntity = new BaseEntity(this.game, new Vector3(0.0f, 165.0f, 0.0f), Matrix.Identity, 1.0f);

            this.game.SceneManager.AddEntityByTemplateID(newEntity, 10);

            int size = 4096;

            if (this.game.TerrainID != QSGame.UniqueIDEmpty)
            {
                var msgGetTerrainProps = ObjectPool.Aquire <MsgGetTerrainProperties>();
                msgGetTerrainProps.UniqueTarget = this.game.TerrainID;
                this.game.SendMessage(msgGetTerrainProps);

                size  = msgGetTerrainProps.Size;
                size *= msgGetTerrainProps.TerrainScale;
            }

            WaterComponent waterComp = newEntity.GetComponentByType(ComponentType.WaterComponent) as WaterComponent;

            waterComp.SetupWaterVertices(size, size);
        }
Esempio n. 8
0
        static public BaseComponent LoadComponent(BaseEntity parent, ComponentType type, ContentManager contentManager, string XMLDefinitionPath)
        {
            // This is a factory for creating any component based on a ComponentType
            switch (type)
            {
            case ComponentType.RenderComponent:
            {
                BaseComponent newComponent = RenderComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CameraComponent:
            {
                BaseComponent newComponent = CameraComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantMovementComponent:
            {
                BaseComponent newComponent = ConstantMovementComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ConstantRotationComponent:
            {
                BaseComponent newComponent = ConstantRotationComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.FreeCameraInputComponent:
            {
                BaseComponent newComponent = FreeCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.LightEmitterComponent:
            {
                BaseComponent newComponent = LightEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhysicsComponent:
            {
                BaseComponent newComponent = PhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.PhantomPhysicsComponent:
            {
                BaseComponent newComponent = PhantomPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterPhysicsComponent:
            {
                BaseComponent newComponent = CharacterPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CharacterInputComponent:
            {
                BaseComponent newComponent = CharacterInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterComponent:
            {
                BaseComponent newComponent = WaterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ArcBallCameraInputComponent:
            {
                BaseComponent newComponent = ArcBallCameraInputComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.ParticleEmitterComponent:
            {
                BaseComponent newComponent = ParticleEmitterComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.SkyDomeComponent:
            {
                BaseComponent newComponent = SkyDomeComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.CollisionTriggerComponent:
            {
                BaseComponent newComponent = CollisionTriggerComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainComponent:
            {
                BaseComponent newComponent = TerrainComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.TerrainPhysicsComponent:
            {
                BaseComponent newComponent = TerrainPhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.WaterVolumePhysicsComponent:
            {
                BaseComponent newComponent = WaterVolumePhysicsComponent.LoadFromDefinition(contentManager, XMLDefinitionPath, parent);
                CheckComponentLoadedProperly(newComponent, type);

                return(newComponent);
            }

            case ComponentType.Invalid:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }

            default:
            {
                throw new ArgumentException(String.Format("Invalid component type passed, type {0} is not valid", type));
            }
            }
        }
Esempio n. 9
0
 private void OnIrrigated(WaterComponent obj)
 {
     GridObject.ParentGrid.SetGridObject(GridObject.EType.Grass);
 }