Example #1
0
    public bool RemoveFish(PlayerInteractionController playerControllerScript, GameData.FishType fishType)
    {
        if (currentLevelSchools.ContainsKey(fishType))
        {
            FishSchoolController schoolController = currentLevelSchools[fishType];
            if (schoolController != null)
            {
                if (schoolController.FishInSchool.Count > 0)
                {
                    GameObject             fishToRemove           = schoolController.RemoveFishFromSchool(0);
                    FishMovementController fishMovementController = fishToRemove.GetComponent <FishMovementController>();
                    if (fishMovementController != null)
                    {
                        fishMovementController.SetEnabled(false);
                        FishController fishController = fishToRemove.GetComponent <FishController>();
                        if (fishController != null)
                        {
                            fishController.SetEnabled(true);
                            playerControllerScript.PickUpObject(fishToRemove);

                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }
Example #2
0
    public void Init(GameData.FishType type)
    {
        fishTypeIndex = type;

        numResearched.text = GameData.GetFishParameters(fishTypeIndex).totalResearched.ToString();
        numToResearch.text = GameData.GetFishParameters(fishTypeIndex).totalToResearch.ToString();
    }
Example #3
0
    public void StoreFish(GameObject fishToStore, GameData.FishType fishType)
    {
        if (fishToStore != null)
        {
            FishSchoolController schoolController = currentLevelSchools[fishType];
            if (schoolController != null)
            {
                FishController fishController = fishToStore.GetComponent <FishController>();
                if (fishController != null)
                {
                    fishController.StartSlowPanic();
                    fishController.SetEnabled(false);
                    FishMovementController fishMovementController = fishToStore.GetComponent <FishMovementController>();
                    if (fishMovementController != null)
                    {
                        fishMovementController.SetEnabled(true);
                        fishMovementController.Initialise();
                        schoolController.AddFishToSchool(fishToStore);
                        fishToStore.transform.position = holdSlot.transform.position;
                    }

                    // I don't know why I must do this, but I must delay setting the parent else it will force set itself to no parent
                    StartCoroutine(GameController.ActivateCallbackAfterDelayCoroutine(1f, () =>
                    {
                        fishController.transform.SetParent(schoolController.transform);
                    }));
                }
            }
        }
    }
Example #4
0
    public void Setup(GameData.FishType type, SkinnedMeshRenderer mesh, Animator animator)
    {
        fishType     = type;
        fishRenderer = mesh;
        fishAnimator = animator;

        Setup();
    }
Example #5
0
    public void Init(GameData.FishType type, GameObject anchor)
    {
        fishTypeIndex    = type;
        anchorGameObject = anchor;
        fishName         = transform.Find("FishName").GetComponent <Text>();
        rectTransform    = gameObject.GetComponent <RectTransform>();

        fishName.text = GameData.GetFishName(fishTypeIndex).ToString();
    }
Example #6
0
 private bool IsFishTypeStoreable(GameData.FishType fishType)
 {
     for (int i = 0; i < researchRequirementsForLevel.Length; i++)
     {
         if (fishType == researchRequirementsForLevel[i])
         {
             return(true);
         }
     }
     return(false);
 }
 public void SetWireframe(GameData.FishType fishType)
 {
     for (int i = 0; i < wireframes.Length; i++)
     {
         wireframes[i].templateObject.SetActive(false);
         if (wireframes[i].fishType == fishType)
         {
             wireframes[i].templateObject.SetActive(true);
         }
     }
 }
Example #8
0
    // Use this for initialization
    void Start()
    {
        /*
         * zoneBoundaryXPos = gameObject.transform.Find("ZoneColliderXPos").gameObject;
         * zoneBoundaryXNeg = gameObject.transform.Find("ZoneColliderXNeg").gameObject;
         * zoneBoundaryYPos = gameObject.transform.Find("ZoneColliderYPos").gameObject;
         * zoneBoundaryYNeg = gameObject.transform.Find("ZoneColliderYNeg").gameObject;
         * zoneBoundaryZPos = gameObject.transform.Find("ZoneColliderZPos").gameObject;
         * zoneBoundaryZNeg = gameObject.transform.Find("ZoneColliderZNeg").gameObject;
         *
         * zoneBoundaryXPos.transform.localScale = new Vector3(1, zoneHeight * 2, zoneLength * 2);
         * zoneBoundaryXNeg.transform.localScale = new Vector3(1, zoneHeight * 2, zoneLength * 2);
         * zoneBoundaryYPos.transform.localScale = new Vector3(zoneWidth * 2, 1, zoneLength * 2);
         * zoneBoundaryYNeg.transform.localScale = new Vector3(zoneWidth * 2, 1, zoneLength * 2);
         * zoneBoundaryZPos.transform.localScale = new Vector3(zoneWidth * 2, zoneHeight * 2, 1);
         * zoneBoundaryZNeg.transform.localScale = new Vector3(zoneWidth * 2, zoneHeight * 2, 1);
         *
         * zoneBoundaryXPos.transform.localPosition = new Vector3(zoneWidth, 0, 0);
         * zoneBoundaryXNeg.transform.localPosition = new Vector3(-zoneWidth, 0, 0);
         * zoneBoundaryYPos.transform.localPosition = new Vector3(0, zoneHeight, 0);
         * zoneBoundaryYNeg.transform.localPosition = new Vector3(0, -zoneHeight, 0);
         * zoneBoundaryZPos.transform.localPosition = new Vector3(0, 0, zoneLength);
         * zoneBoundaryZNeg.transform.localPosition = new Vector3(0, 0, -zoneLength);
         */
        zoneCollider.transform.localScale = new Vector3(zoneX * 2, zoneY * 2, zoneZ * 2);
        zoneCollider.name = gameObject.ToString();

        // Set Zone as a child of Sea
        this.transform.SetParent(Sea);

        fishSchools = new Dictionary <GameData.FishType, List <GameObject> >();
        for (int i = 0; i < GameData.TOTAL_NUMBER_OF_FISHTYPES_INCLUDING_TUTORIAL; i++)
        {
            GameData.FishType fishType = (GameData.FishType)i;
            fishSchools.Add(fishType, new List <GameObject>());
        }

        numSchools = Random.Range(minSchools, maxSchools);
        StartCoroutine(SpawnSchools());
    }
Example #9
0
 // Use this for initialization
 void Start()
 {
     fishTypeIndex = 0;
 }
Example #10
0
    // Use this for initialization
    void Start()
    {
        warningText.SetActive(false);

        previousSchools = new List <FishSchoolController>();
        for (int i = 0; i < PersistentData.Obj.savedSchools.Count; i++)
        {
            PersistentData.AquariumSchoolData persistentData = PersistentData.Obj.savedSchools[i];
            GameData.FishType       fishTypeToSpawn          = persistentData.fishType;
            GameData.FishParameters fishParameters           = GameData.GetFishParameters(fishTypeToSpawn);

            GameObject newFishSchool = (GameObject)Instantiate(fishSchool);
            newFishSchool.transform.position = holdSlot.transform.position;
            newFishSchool.transform.SetParent(gameObject.transform);
            FishSchoolController fishSchoolController = newFishSchool.GetComponent <FishSchoolController>();
            fishSchoolController.zoneX = 20;
            fishSchoolController.zoneY = 10;
            fishSchoolController.zoneZ = 5;

            for (int j = 0; j < persistentData.numberOfFishes; j++)
            {
                FishController         newFish = GameData.CreateNewFish(fishTypeToSpawn, newFishSchool.transform);
                FishMovementController fishMovementController = newFish.GetComponent <FishMovementController>();
                fishMovementController.Initialise
                (
                    fishParameters.minSpeed,
                    fishParameters.maxSpeed,
                    fishParameters.minRotationSpeed,
                    fishParameters.maxRotationSpeed,
                    fishParameters.minNeighbourDistance
                );
                fishMovementController.SetEnabled(true);
                newFish.SetRigidbody(false);
                newFish.gameObject.transform.position = holdSlot.transform.position
                                                        + new Vector3(Random.Range(-2, 2),
                                                                      Random.Range(-2, 2),
                                                                      Random.Range(-2, 2));
                fishSchoolController.AddFishToSchool(newFish.gameObject);
            }
            previousSchools.Add(fishSchoolController);
        }

        currentLevelSchools      = new Dictionary <GameData.FishType, FishSchoolController>();
        fishResearchRequirements = new Dictionary <GameData.FishType, GameObject>();
        if (isTutorial)
        {
            researchRequirementsForLevel = GameData.GetResearchRequirementsForLevel(0);
        }
        else
        {
            researchRequirementsForLevel = GameData.GetResearchRequirementsForLevel(GameController.Obj.CurrentLevel);
        }

        for (int i = 0; i < researchRequirementsForLevel.Length; i++)
        {
            GameObject newFishSchool = (GameObject)Instantiate(fishSchool);
            newFishSchool.transform.position = holdSlot.transform.position;
            newFishSchool.transform.SetParent(GameController.Obj.AquariumHolder);
            FishSchoolController fishSchoolController = newFishSchool.GetComponent <FishSchoolController>();
            fishSchoolController.zoneX = 10;
            fishSchoolController.zoneY = 5;
            fishSchoolController.zoneZ = 10;
            currentLevelSchools.Add(researchRequirementsForLevel[i], fishSchoolController);

            Transform newFishResearchRequirements = Instantiate(GameData.GetSelectableFish(researchRequirementsForLevel[i]));
            newFishResearchRequirements.SetParent(researchReqAnchor.transform, false);
            newFishResearchRequirements.Translate(0 + (i * 5), 0, 0);
            newFishResearchRequirements.GetComponent <ResearchRequirementsController>().Init(researchRequirementsForLevel[i]);
            fishResearchRequirements.Add(researchRequirementsForLevel[i], newFishResearchRequirements.gameObject);
        }
    }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        if (warningText.activeSelf)
        {
            if (warningTextLifespan < 3)
            {
                warningTextLifespan += Time.deltaTime;
            }
            else
            {
                warningTextLifespan = 0;
                warningText.SetActive(false);
            }
        }

        if (this.IsActivated && playerInStation != null)
        {
            if (selectInterval > 0.2f)
            {
                if (playerInStation.controls.GetHorizontalAxis() > 0)
                {
                    selectInterval = 0;

                    if (selectedResearchRequirementIndex == -1)
                    {
                        selectedResearchRequirementIndex = 0;
                        fishResearchRequirements[researchRequirementsForLevel[selectedResearchRequirementIndex]].GetComponent <ResearchRequirementsController>().Select();
                    }
                    else if (selectedResearchRequirementIndex < (researchRequirementsForLevel.Length - 1))
                    {
                        GameData.FishType fishType = researchRequirementsForLevel[selectedResearchRequirementIndex];
                        fishResearchRequirements[fishType].GetComponent <ResearchRequirementsController>().Deselect();
                        selectedResearchRequirementIndex++;
                        fishType = researchRequirementsForLevel[selectedResearchRequirementIndex];
                        fishResearchRequirements[fishType].GetComponent <ResearchRequirementsController>().Select();
                    }
                }
                else if (playerInStation.controls.GetHorizontalAxis() < 0)
                {
                    selectInterval = 0;
                    if (selectedResearchRequirementIndex == -1)
                    {
                        selectedResearchRequirementIndex = 0;
                        fishResearchRequirements[researchRequirementsForLevel[selectedResearchRequirementIndex]].GetComponent <ResearchRequirementsController>().Select();
                    }
                    else if (selectedResearchRequirementIndex > 0)
                    {
                        GameData.FishType fishType = researchRequirementsForLevel[selectedResearchRequirementIndex];
                        fishResearchRequirements[fishType].GetComponent <ResearchRequirementsController>().Deselect();
                        selectedResearchRequirementIndex--;
                        fishType = researchRequirementsForLevel[selectedResearchRequirementIndex];
                        fishResearchRequirements[fishType].GetComponent <ResearchRequirementsController>().Select();
                    }
                }
            }
            else
            {
                selectInterval += Time.deltaTime;
            }

            if (playerInStation.controls.GetCancelKeyDown())
            {
                PlayerController playerControllerScript = this.playerInStation.GetComponent <PlayerController>();
                if (playerControllerScript != null)
                {
                    DisengagePlayer();
                }
            }
            else if (playerInStation.controls.GetActionKeyDown())
            {
                PlayerInteractionController playerControllerScript = this.playerInStation.GetComponent <PlayerInteractionController>();
                if (playerControllerScript != null)
                {
                    if (selectedResearchRequirementIndex >= 0 && selectedResearchRequirementIndex < (researchRequirementsForLevel.Length - 1))
                    {
                        if (RemoveFish(playerControllerScript, researchRequirementsForLevel[selectedResearchRequirementIndex]))
                        {
                            DisengagePlayer();
                        }
                        else
                        {
                            ShowWarningText("No fish of this type is in the aquarium!");
                        }
                    }
                }
            }
        }
    }