Beispiel #1
0
    // Function to check for player collision
    public void OnCollisionEnter(Collision collision)
    {
        // Rock Paper Scissors Scenarios

        // Make sure collission  with an enemy
        if (collision.gameObject.tag == "Enemy")
        {
            ShapeScript enemyScript = collision.gameObject.GetComponent <ShapeScript> ();

            // Rock conditions
            if (CurrentShape == "Rock")
            {
                if (enemyScript.CurrentShape == "Scissors")
                {
                    Destroy(collision.gameObject);
                }
                if (enemyScript.CurrentShape == "Paper")
                {
                    CurrentShape = "Paper";
                    // TODO: Need to add some sort of animation/mesh transformation here
                }
            }

            // Rock conditions
            if (CurrentShape == "Paper")
            {
                if (enemyScript.CurrentShape == "Rock")
                {
                    Destroy(collision.gameObject);
                }
                if (enemyScript.CurrentShape == "Scissors")
                {
                    CurrentShape = "Scissors";
                    // TODO: Need to add some sort of animation/mesh transformation here
                }
            }

            // Rock conditions
            if (CurrentShape == "Scissors")
            {
                if (enemyScript.CurrentShape == "Paper")
                {
                    Destroy(collision.gameObject);
                }
                if (enemyScript.CurrentShape == "Rock")
                {
                    CurrentShape = "Rock";
                    // TODO: Need to add some sort of animation/mesh transformation here
                }
            }
        }
    }
 public void Init(ShapeScript shape, bool showFraction = false, bool showLabel = true)
 {
     _shapePrefab = shape.gameObject;
     text.text    = shape.ShapeName;
     fraction.SetFraction(shape.Fraction);
     if (!showFraction)
     {
         Destroy(fractionText.gameObject);
     }
     if (!showLabel)
     {
         Destroy(label);
     }
 }
Beispiel #3
0
 public override void ShapeAdded(ShapeScript shape)
 {
     CurrentGoal.ShapeAdded(shape);
     if (CurrentGoal.GetOutcome() != Outcome.Achieved)
     {
         return;
     }
     _goalIndex++;
     if (_goalIndex >= goals.Count)
     {
         EventManager.Instance.sunk?.Invoke();
     }
     else
     {
         GameManager.Instance.SetupGoal();
     }
 }
Beispiel #4
0
    void CreateShapes()
    {
        answer = GenerateAnswer(level).ToString();

        int numberOfShapes = Con.Constants.GetNumberOfQuestions(level);

        double[,] positions = new double[numberOfShapes, 2];



        for (int i = 0; i < numberOfShapes; i++)
        {
            GameObject  shape  = (GameObject)Instantiate(Resources.Load("Circle"), new Vector3(i * 4, 0, 0), Quaternion.identity);
            ShapeScript script = shape.GetComponent <ShapeScript> ();
            script.UploadColor(colors [rand.Next(colors.Length)]);

            script.UploadSprite(Con.Constants.SPRITE_NAMES[rand.Next(Con.Constants.SPRITE_NAMES.GetLength(0))]);

            double[] newPos = new double[2];
            newPos = GetRandomPositions();

            while (!IsNewPositionValid(positions, newPos))
            {
                newPos = GetRandomPositions();
            }


            positions [i, 0] = newPos [0];
            positions [i, 1] = newPos [1];

            script.UploadPosition(newPos [0], newPos [1]);

            if (i == 0)
            {
                script.UpdateEqu(level, true, int.Parse(answer));
            }
            else
            {
                script.UpdateEqu(level, false, int.Parse(answer));
            }

            shapes.Add(shape);
            Debug.Log("Create shapes method finished");
        }
    }
        public override void ShapeAdded(ShapeScript shape)
        {
            if (isTutorial)
            {
                if (shape.Equals(goalShape))
                {
                    ScreenManager.Instance.FlashResult(true);
                    _givenShape = shape;
                }
                else
                {
                    ScreenManager.Instance.FlashResult(false);
                    return;
                }
            }

            else
            {
                _givenShape = shape;
            }

            _machineText.text = "Now turn the handle ->";
        }
 public override void ClearScreen()
 {
     _givenShape       = null;
     _machineText.text = machineMessage;
 }
    void SaveLevel()
    {
        completeJSON = string.Empty;
        ObjectData[] objs       = FindObjectsOfType <ObjectData>();
        LevelData    level      = new LevelData();
        int          nbOfGreens = 0;

        for (int i = 0; i < objs.Length; i++)
        {
            Renderer renderer;
            if (objs[i].GetComponentInChildren <ModularPlatform>())
            {
                renderer = objs[i].GetComponentsInChildren <Renderer>()[1];
            }
            else
            {
                renderer = objs[i].GetComponentInChildren <Renderer>();
            }

            if (!renderer.enabled)
            {
                continue;
            }

            SetPrefixJSON("ObjectInfo");
            ObjectInfo info = new ObjectInfo();
            objs[i].objectID = objs[i].GetInstanceID();
            info.objectID    = objs[i].objectID;
            info.position    = objs[i].transform.position;
            info.rotation    = objs[i].transform.eulerAngles;
            info.scale       = objs[i].transform.localScale;
            info.prefab      = objs[i].prefab.name;
            info.toolName    = objs[i].toolName;
            if (objs[i].GetComponent <ShapeScript>())
            {
                ShapeScript shapeScript = objs[i].GetComponent <ShapeScript>();
                if (shapeScript.isGreen)
                {
                    info.isCube = "isGreen";
                    ++nbOfGreens;
                }
                else if (shapeScript.isHeavy)
                {
                    info.isCube = "isHeavy";
                }
                else if (shapeScript.isNight)
                {
                    info.isCube = "isNight";
                }
                else if (shapeScript.isRed)
                {
                    info.isCube = "isRed";
                }
                else if (objs[i].GetComponent <Rigidbody>().isKinematic)
                {
                    info.isCube = "isKinematic";
                }
                else
                {
                    info.isCube = "isNormal";
                }
            }
            else if (objs[i].GetComponentInChildren <ModularPlatform>())
            {
                info.platformInfo = FillPlatformInfo(objs[i].gameObject);
            }

            level.objectsInfoList.Add(info);
            AddToJSON(info);
        }
        #region neededToWin
        {
            SetPrefixJSON("Rule");
            Rule winRule = new Rule()
            {
                neededToWin = nbOfGreens.ToString()
            };
            AddToJSON(winRule);
        }
        #endregion
        for (int i = 0; i < rulesInputs.Length; ++i)
        {
            SetPrefixJSON("Rule");
            Rule rule = new Rule()
            {
                toolName   = rulesInputs[i].name,
                toolAmount = rulesInputs[i].text
            };
            AddToJSON(rule);
        }
        LookForSaveFileLocation();
    }
 // TODO Make this better x10000
 public override void ShapeAdded(ShapeScript shape)
 {
     _fractions[GameManager.Instance.GrinderShapes.Count - 1].SetFraction(shape.Fraction, Color.red);
 }
 public override void ShapeAdded(ShapeScript shape)
 {
     _screenText.text += $"{GameManager.Instance.GrinderShapes.Count}. {shape.ShapeName}\n";
 }
 protected bool Equals(ShapeScript other)
 {
     return(faces == other.faces && edges == other.edges && vertices == other.vertices && shapeName == other.shapeName && fraction.Equals(other.fraction));
 }
Beispiel #11
0
 public abstract void ShapeAdded(ShapeScript shape);