Ejemplo n.º 1
0
    public void SetGravity(FloatingObject floatie)
    {
        floatie.hoverForce  = hoverForce;
        floatie.hoverDampen = hoverDampen;

        floatie.ArenaDown = Center - floatie.transform.position.normalized;
    }
Ejemplo n.º 2
0
 internal void RefreshFloatingObjectContainerIsSelected(FloatingObject floatingObject)
 {
     if (FloatingObjectsPanel != null)
     {
         FloatingObjectsPanel.RefreshContainerIsSelected(floatingObject);
     }
 }
Ejemplo n.º 3
0
        void ArrangePictures()
        {
            if (_cachedPictures.Count == 0)
            {
                return;
            }

            FloatingObjectLayoutModel viewportFloatingObjectLayoutModel = ParentViewport.Excel.GetViewportFloatingObjectLayoutModel(RowViewportIndex, ColumnViewportIndex);

            foreach (PictureContainer container in _cachedPictures.Values)
            {
                FloatingObject       floatingObject = container.FloatingObject;
                Point                location       = new Point(0.0, 0.0);
                Size                 size           = new Size(0.0, 0.0);
                FloatingObjectLayout layout         = viewportFloatingObjectLayoutModel.Find(floatingObject.Name);
                if (layout != null)
                {
                    double num  = 7.0;
                    double num2 = 1.0;
                    location = new Point(((layout.X - Location.X) - num) - num2, ((layout.Y - Location.Y) - num) - num2);
                    size     = new Size(layout.Width + (2.0 * num), layout.Height + (2.0 * num));
                }
#if !IOS
                container.InvalidateArrange();
#endif
                container.Arrange(new Rect(location, size));
            }
        }
Ejemplo n.º 4
0
    void Start()
    {
        maxParticles   = (int)((1f / emitTimeInterval) * emitPerCycle * particleLifetime);
        waterParticles = new WaterParticle[maxParticles];

        CheckCurves();

        pIndex = 0;

        GameObject masterContainer = GameObject.Find("WaterFX Particles");

        if (masterContainer == null)
        {
            masterContainer      = new GameObject();
            masterContainer.name = "WaterFX Particles";
        }

        fo = GetComponent <FloatingObject>();
        particleContainer = new GameObject();
        particleContainer.transform.parent = masterContainer.transform;
        particleContainer.name             = "Water Particles (" + fo.gameObject.name + ")";

        foamTexCount = foamTextures.Count;
        if (foamTexCount == 0)
        {
            Debug.LogWarning("No foam textures assigned to object " + gameObject.name + ". Will not emit any particles");
        }
    }
Ejemplo n.º 5
0
        public void TestNewRuleReturnsCorrectMetabolicRule()
        {
            FloatingObject           floatingObject = new FloatingObject("a", 1, 1);
            Protein                  protein        = new Protein("p1");
            List <ISimulationObject> leftSide       = new List <ISimulationObject> {
                floatingObject, protein
            };
            List <ISimulationObject> rightSide = new List <ISimulationObject> {
                protein, floatingObject
            };
            EvoMetabolicRule metabolicRule = TypeUtil.Cast <EvoMetabolicRule>(EvolutionRule.NewRule("Metabolic", 0, leftSide, rightSide, 0));

            Assert.AreEqual(0, metabolicRule.Priority);
            Assert.AreEqual(EvolutionRule.RuleType.Metabolic, metabolicRule.Type);
            Assert.AreEqual(EvoMetabolicRule.MetabolicRuleType.Symport, metabolicRule.SubType);
            Assert.AreEqual(2, metabolicRule.LeftSideObjects.Count);
            Assert.AreEqual("a", metabolicRule.LeftSideObjects[0].Name);
            Assert.AreEqual("p1", metabolicRule.LeftSideObjects[1].Name);
            Assert.AreEqual(2, metabolicRule.RightSideObjects.Count);
            Assert.AreEqual("p1", metabolicRule.RightSideObjects[0].Name);
            Assert.AreEqual("a", metabolicRule.RightSideObjects[1].Name);
            Assert.AreEqual(0, metabolicRule.MLeftInNames.Count);
            Assert.AreEqual(1, metabolicRule.MLeftOutNames.Count);
            Assert.AreEqual(1, metabolicRule.MLeftOutNames.ToDictionary()["a"]);
            Assert.AreEqual(1, metabolicRule.MRightInNames.Count);
            Assert.AreEqual(1, metabolicRule.MRightInNames.ToDictionary()["a"]);
            Assert.AreEqual(0, metabolicRule.MRightOutNames.Count);
            Assert.AreEqual("p1", metabolicRule.RProtein.Name);
        }
Ejemplo n.º 6
0
        public void TestNewRuleReturnsCorrectNonMetabolicRule()
        {
            Glue                     glue           = new Glue("pa");
            FloatingObject           floatingObject = new FloatingObject("a", 1, 1);
            List <ISimulationObject> leftSide       = new List <ISimulationObject> {
                glue, glue, floatingObject, floatingObject
            };
            List <ISimulationObject> rightSide = new List <ISimulationObject> {
                glue, glue
            };
            EvoNonMetabolicRule divideRule = TypeUtil.Cast <EvoNonMetabolicRule>(EvolutionRule.NewRule("Divide", 1, leftSide, rightSide, 0));

            Assert.AreEqual(1, divideRule.Priority);
            Assert.AreEqual(EvolutionRule.RuleType.Divide, divideRule.Type);
            Assert.AreEqual(4, divideRule.LeftSideObjects.Count);
            Assert.AreEqual("pa", divideRule.LeftSideObjects[0].Name);
            Assert.AreEqual("pa", divideRule.LeftSideObjects[1].Name);
            Assert.AreEqual("a", divideRule.LeftSideObjects[2].Name);
            Assert.AreEqual("a", divideRule.LeftSideObjects[3].Name);
            Assert.AreEqual(2, divideRule.RightSideObjects.Count);
            Assert.AreEqual("pa", divideRule.RightSideObjects[0].Name);
            Assert.AreEqual("pa", divideRule.RightSideObjects[1].Name);
            Assert.AreEqual(2, divideRule.MLeftSideFloatingNames.Count);
            Assert.AreEqual(2, divideRule.MLeftSideFloatingNames.ToDictionary()["a"]);
            Assert.AreEqual(0, divideRule.MRightSideFloatingNames.Count);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Undoes the command or operation.
        /// </summary>
        /// <param name="parameter">The parameter to undo the command or operation.</param>
        /// <returns>
        /// <c>true</c> if an undo operation on the command or operation succeeds; otherwise, <c>false</c>.
        /// </returns>
        public bool Undo(object parameter)
        {
            Excel view = parameter as Excel;

            try
            {
                view.SuspendFloatingObjectsInvalidate();
                SaveState();
                foreach (string str in _movingExtent.Names)
                {
                    FloatingObject obj2 = _worksheet.FindChart(str);
                    if (obj2 == null)
                    {
                        obj2 = _worksheet.FindPicture(str);
                    }
                    if (obj2 == null)
                    {
                        obj2 = _worksheet.FindFloatingObject(str);
                    }
                    if (obj2 != null)
                    {
                        obj2.Location = new Point(obj2.Location.X - _movingExtent.OffsetX, obj2.Location.Y - _movingExtent.OffsetY);
                    }
                }
            }
            finally
            {
                view.ResumeFloatingObjectsInvalidate();
            }
            view.InvalidateFloatingObjectLayout();
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Saves the state for undoing the command or operation.
        /// </summary>
        public void SaveState()
        {
            List <SpreadChart>    list  = new List <SpreadChart>();
            List <FloatingObject> list2 = new List <FloatingObject>();
            List <Picture>        list3 = new List <Picture>();

            foreach (string str in _deleteExtent.Names)
            {
                SpreadChart chart = _worksheet.FindChart(str);
                if (chart != null)
                {
                    list.Add(chart);
                }
                else
                {
                    Picture picture = _worksheet.FindPicture(str);
                    if (picture != null)
                    {
                        list3.Add(picture);
                    }
                    else
                    {
                        FloatingObject obj2 = _worksheet.FindFloatingObject(str);
                        if (obj2 != null)
                        {
                            list2.Add(obj2);
                        }
                    }
                }
            }
            _savedCharts   = list.ToArray();
            _savedPictures = list3.ToArray();
            _savedObjects  = list2.ToArray();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Defines the method to be called when the action is invoked.
 /// </summary>
 /// <param name="parameter">Data used by the action. If the action does not require data to be passed, this object can be set to null.</param>
 public override void Execute(object parameter)
 {
     if (CanExecute(parameter))
     {
         Excel view = parameter as Excel;
         try
         {
             view.SuspendFloatingObjectsInvalidate();
             SaveState();
             foreach (string str in _movingExtent.Names)
             {
                 FloatingObject obj2 = _worksheet.FindChart(str);
                 if (obj2 == null)
                 {
                     obj2 = _worksheet.FindPicture(str);
                 }
                 if (obj2 == null)
                 {
                     obj2 = _worksheet.FindFloatingObject(str);
                 }
                 if (obj2 != null)
                 {
                     obj2.Location = new Point(obj2.Location.X + _movingExtent.OffsetX, obj2.Location.Y + _movingExtent.OffsetY);
                 }
             }
         }
         finally
         {
             view.ResumeFloatingObjectsInvalidate();
         }
         view.InvalidateFloatingObjectLayout();
     }
 }
    public void Calculate()
    {
        fos = GetComponentsInChildren <FloatingObject>();

        if (fos.Length > 0)
        {
            rb = GetComponent <Rigidbody>();
            float massSum = 0;

            foreach (FloatingObject fo in fos)
            {
                massSum += fo.MaterialMass;
            }

            FloatingObject f = null;
            if (f = GetComponent <FloatingObject>())
            {
                massSum += f.MaterialMass;
            }

            if (massSum > 1)
            {
                rb.mass = massSum;
            }
        }
    }
Ejemplo n.º 11
0
    // Generating Floating Objects from script at runtime is limited in features and it is recommended
    // to do it from Editor if possible.

    // !!! Do not use mesh simplification during the runtime as it can take up to few seconds !!!
    // Below is the example of all the things that you can do with the FloatingObject.cs script,
    // but it is recommended that you use prefabs rather than generate objects during runtime,
    // and then modify the values of the instantiated prefab using GetComponent<>().

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            // Create game object
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            go.name = "Demo Floating Object From Script";
            go.transform.position = new Vector3(0, 3, 0);

            // Add rigidbody
            Rigidbody rb = go.AddComponent <Rigidbody>();
            rb.mass = 200;

            // Add floating object script
            FloatingObject fo = go.AddComponent <FloatingObject>();

            // Optional params (can be removed, just for demo)
            fo.FluidDensity       = 1000;
            fo.DynamicForceFactor = 1f;

            // Manually assigning water - flat
            // If not set floating object will use the nearest water object with tag "Water",
            // or if no such objects exist will assume water is at height 0.

            //fo.water = myWaterGameObject;

            // Assigning water - waves

            //fo.water = GameObject.Find("WaterWithWaves");
            //fo.WaterHeightFunction = ExampleWaterHeightFunction;

            // Get underwater triangle data
            // List<BuoyTri> tris = fo.underwaterTris;
        }
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Undoes the command or operation.
        /// </summary>
        /// <param name="parameter">The parameter to undo the command or operation.</param>
        /// <returns>
        /// <c>true</c> if an undo operation on the command or operation succeeds; otherwise, <c>false</c>.
        /// </returns>
        public bool Undo(object parameter)
        {
            Excel view = parameter as Excel;

            try
            {
                view.SuspendFloatingObjectsInvalidate();
                for (int i = 0; i < _resizingExtent.Names.Length; i++)
                {
                    string         name = _resizingExtent.Names[i];
                    FloatingObject obj2 = _worksheet.FindChart(name);
                    if (obj2 == null)
                    {
                        obj2 = _worksheet.FindPicture(name);
                    }
                    if (obj2 == null)
                    {
                        obj2 = _worksheet.FindFloatingObject(name);
                    }
                    if (obj2 != null)
                    {
                        Rect rect = _savedRects[i];
                        obj2.Location = new Point(rect.X, rect.Y);
                        obj2.Size     = new Size(rect.Width, rect.Height);
                    }
                }
            }
            finally
            {
                view.ResumeFloatingObjectsInvalidate();
            }
            view.InvalidateFloatingObjectLayout();
            return(true);
        }
Ejemplo n.º 13
0
    private void OnGameBuilt(object sender)
    {
        floatingObject = GetComponent <FloatingObject>();

        powerController = GetComponent <PowerController>();
        powerController.EventPowerAttached += OnEventPowerAttached;

        game = GameObject.FindGameObjectWithTag(Tags.Game).GetComponent <Game>();
        game.EventShipEliminated += OnShipEliminated;
        game.EventEnd            += OnEventEnd;

        // Listen all event fights
        foreach (GameObject ship in game.ShipsInGame)
        {
            TailController tailController = ship.GetComponent <TailController>();
            tailController.OnEventFight += OnEventFight;
        }

        gameObject.GetComponent <Tail>().OnEventOrbAttached += OnEventOrbAttached;
        // Attaching field of view notification
        GetComponentInChildren <AIFieldOfView>().EventOnFieldOfViewEnter += OnFieldOfViewEnter;
        checkpoints = new HashSet <GameObject>(GameObject.FindGameObjectsWithTag(Tags.AICheckpoint));


        gameBuilt = true;
    }
Ejemplo n.º 14
0
        internal void RefreshContainerIsSelected(FloatingObject floatingObject)
        {
            SpreadChartContainer container = null;

            if (_cachedCharts.TryGetValue(floatingObject.Name, out container))
            {
                container.RefreshIsSelected();
            }
            else
            {
                PictureContainer container2 = null;
                if (_cachedPictures.TryGetValue(floatingObject.Name, out container2))
                {
                    container2.RefreshIsSelected();
                }
                else
                {
                    FloatingObjectContainer container3 = null;
                    if (_cachedFloatingObjects.TryGetValue(floatingObject.Name, out container3))
                    {
                        container3.RefreshIsSelected();
                    }
                }
            }
        }
Ejemplo n.º 15
0
    public void LookAt(GameObject target)
    {
        Target = target;

        // Setting up the reference.
        player            = target.transform;
        FloatingComponent = target.GetComponent <FloatingObject>();
    }
Ejemplo n.º 16
0
 public void Restart()
 {
     _gravity        = SceneManager.Instance.GetGravity();
     _animator       = GetComponent <Animator>();
     _audioSource    = this.GetComponent <AudioSource>();
     _floatingObject = GetComponent <FloatingObject>();
     _audioSource.Play();
 }
Ejemplo n.º 17
0
    private void AddObject(FloatingObject source)
    {
        GameObject temp = GameObject.Instantiate(source.gameObject);

        temp.name = source.name;
        _objects.Add(temp.GetComponent <FloatingObject>());
        temp.SetActive(false);
    }
Ejemplo n.º 18
0
    void Update()
    {
        if (!isPlaying)
        {
            return;
        }

        FloatingObject.Float(lFloatingSpeed * Time.deltaTime);
    }
Ejemplo n.º 19
0
    public ObjectPool(int count, FloatingObject source)
    {
        _objects = new List <FloatingObject>();

        for (int i = 0; i < count; i++)
        {
            AddObject(source);
        }
    }
Ejemplo n.º 20
0
    public void Initialize(int count, FloatingObject source)
    {
        _objects = new List <FloatingObject>();

        for (int i = 0; i < count; i++)
        {
            AddObject(source);
        }
    }
Ejemplo n.º 21
0
    static public void Float(float distance)
    {
        for (var it = floatings.First; it != null;)
        {
            FloatingObject obj = it.Value;
            it = it.Next;

            obj.floatImpl(distance);
        }
    }
Ejemplo n.º 22
0
 /// <summary>
 /// Defines the method to be called when the action is invoked.
 /// </summary>
 /// <param name="parameter">Data used by the action. If the action does not require data to be passed, this object can be set to null.</param>
 public override void Execute(object parameter)
 {
     if (CanExecute(parameter))
     {
         Excel excel = parameter as Excel;
         try
         {
             excel.SuspendFloatingObjectsInvalidate();
             SaveState();
             for (int i = 0; i < _deleteExtent.Names.Length; i++)
             {
                 string      name  = _deleteExtent.Names[i];
                 SpreadChart chart = _worksheet.FindChart(name);
                 if (chart != null)
                 {
                     _worksheet.RemoveChart(name);
                     chart.IsSelected = false;
                 }
                 else
                 {
                     Picture picture = _worksheet.FindPicture(name);
                     if (picture != null)
                     {
                         _worksheet.RemovePicture(name);
                         picture.IsSelected = false;
                     }
                     else
                     {
                         FloatingObject obj2 = _worksheet.FindFloatingObject(name);
                         if (obj2 != null)
                         {
                             _worksheet.RemoveFloatingObject(name);
                             obj2.IsSelected = false;
                         }
                     }
                 }
             }
         }
         finally
         {
             excel.ResumeFloatingObjectsInvalidate();
             ReadOnlyCollection <CellRange> selections = _worksheet.Selections;
             if (selections.Count != 0)
             {
                 foreach (CellRange range in selections)
                 {
                     excel.UpdateHeaderCellsState(range.Row, range.RowCount, range.Column, range.ColumnCount);
                 }
             }
         }
         excel.InvalidateFloatingObjectLayout();
     }
 }
Ejemplo n.º 23
0
    void OnTriggerEnter(Collider _collider)
    {
        FloatingObject tempFloatingObject = _collider.GetComponent <FloatingObject>();

        if (tempFloatingObject != null)
        {
            // Cache componentes
            rigidbodiesUnderWater.Add(_collider.rigidbody);
            transformsUnderWater.Add(_collider.transform);
            floatingObjectUnderWater.Add(tempFloatingObject);
        }
    }
Ejemplo n.º 24
0
    void OnTriggerExit(Collider _collider)
    {
        FloatingObject tempFloatingObject = _collider.GetComponent <FloatingObject>();

        if (tempFloatingObject != null)
        {
            //Free components
            rigidbodiesUnderWater.Remove(_collider.rigidbody);
            transformsUnderWater.Remove(_collider.transform);
            floatingObjectUnderWater.Remove(tempFloatingObject);
        }
    }
Ejemplo n.º 25
0
        /// <summary>
        /// Deserialize given XML list of floating objects.
        /// </summary>
        /// <param name="floatingObjects">XML element list of floating objects.</param>
        /// <exception cref="MissingXmlAttribute">If some attribute of floating object is missing.</exception>
        /// <exception cref="MissingXmlElement">If some element of floating object is missing.</exception>
        private void DeserializeFloatingObjects(List <XElement> floatingObjects)
        {
            foreach (XElement floatingObject in floatingObjects)
            {
                string name = Xmlizer.GetAttributeValueWithException(floatingObject, "floatingObject", "name");
                AmbiguityTest(name);
                XElement mobilityElement = floatingObject.Element("mobility");
                double   mobility        = Convert.ToDouble(Xmlizer.GetAttributeValueWithException(mobilityElement, "mobility", "value"), CultureInfo.InvariantCulture);
                double   concentration   = GetDouble(floatingObject, "concentration", 0);

                FloatingObjects[name] = new FloatingObject(name, mobility, concentration);
            }
        }
Ejemplo n.º 26
0
    public override void NegateReward()
    {
        base.NegateReward();
        if (m_FloatingObjects.Count > 0)
        {
            //Float object and take it out of the list of objects to float
            FloatingObject floater = m_FloatingObjects[Random.Range(0, m_FloatingObjects.Count)];
            floater.Defloat();

            m_FloatingObjects.Remove(floater);
            m_NotFloatingObjects.Add(floater);
        }
    }
Ejemplo n.º 27
0
 internal void Refresh(object parameter)
 {
     if (!IsSuspendFloatingObjectInvalidate)
     {
         FloatingObject chart = null;
         if (parameter is ChartChangedEventArgs)
         {
             chart = (parameter as ChartChangedEventArgs).Chart;
         }
         else if (parameter is FloatingObjectChangedEventArgs)
         {
             chart = (parameter as FloatingObjectChangedEventArgs).FloatingObject;
         }
         else if (parameter is PictureChangedEventArgs)
         {
             chart = (parameter as PictureChangedEventArgs).Picture;
         }
         if (chart != null)
         {
             FloatingObjectContainer floatingObjectContainer = GetFloatingObjectContainer(chart.Name);
             if (floatingObjectContainer != null)
             {
                 floatingObjectContainer.Refresh(parameter);
             }
         }
         else
         {
             using (Dictionary <string, SpreadChartContainer> .Enumerator enumerator = _cachedCharts.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     enumerator.Current.Value.Refresh(parameter);
                 }
             }
             using (Dictionary <string, PictureContainer> .Enumerator enumerator2 = _cachedPictures.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     enumerator2.Current.Value.Refresh(parameter);
                 }
             }
             using (Dictionary <string, FloatingObjectContainer> .Enumerator enumerator3 = _cachedFloatingObjects.GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     enumerator3.Current.Value.Refresh(parameter);
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
    public void CreateExplosion(Vector3 position)
    {
        _audioSource.Play();

        FloatingObject smoke_clone = _smokePool.GetObject() as FloatingObject;

        smoke_clone.transform.position = position;
        StartCoroutine(smoke_clone.ReturnToPool(_smoke.GetComponent <ParticleSystem>().duration * 2));

        FloatingObject explosion_clone = _explosionPool.GetObject() as FloatingObject;

        explosion_clone.transform.position = position;
        StartCoroutine(explosion_clone.ReturnToPool(_sparkDuration));
    }
Ejemplo n.º 29
0
        public void TestToStringReturnsCompleteString()
        {
            FloatingObject           floatingObject = new FloatingObject("a", 1, 1);
            Protein                  protein        = new Protein("p1");
            List <ISimulationObject> leftSide       = new List <ISimulationObject> {
                floatingObject, protein
            };
            List <ISimulationObject> rightSide = new List <ISimulationObject> {
                protein, floatingObject
            };
            EvolutionRule metabolicRule  = EvolutionRule.NewRule("Metabolic", 0, leftSide, rightSide, 0);
            string        expectedOutput = "Rule: a,p1 -> p1,a, type = Metabolic, priority = 0";

            Assert.AreEqual(expectedOutput, metabolicRule.ToString());
        }
Ejemplo n.º 30
0
    public void SetGravity(FloatingObject floatie)
    {
        floatie.hoverForce  = hoverForce;
        floatie.hoverDampen = hoverDampen;

        //Hypothesis: the torus is aligned along ZX plane
        Vector3 projected_position = new Vector3(floatie.transform.position.x,
                                                 0.0f,
                                                 floatie.transform.position.z);

        //Determinates the center of the circle
        var circle_center = (projected_position - Center).normalized * Radius + Center;

        floatie.ArenaDown = (floatie.transform.position - circle_center).normalized;
    }