示例#1
0
    void OnTriggerEnter(Collider other)
    {
        var baseCollision = other.GetComponent <Base>();

        if (baseCollision != null)
        {
            // TODO: stop from following character and move around
            //          the base normally
            targetToFollow = null;
            atBase         = true;
            if (!baseCollision.followers.Contains(this))
            {
                baseCollision.followers.Add(this);
            }
        }
        else
        {
            if (targetToFollow == null && atBase == false)
            {
                var character = other.GetComponent <MainCharacterController>();
                if (character != null)
                {
                    character.StartInteract(this);
                }
            }
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        /* Once player meets collider, determines which stone is class attached to
         * and sends information to TutorialSceneController.
         */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            if (this.CompareTag("Patsas2"))
            {
                ctrl.activeKivi1();
            }
            else if (this.CompareTag("Patsas3"))
            {
                ctrl.activeKivi2();
            }
            else if (this.CompareTag("Patsas4"))
            {
                ctrl.activeKivi3();
            }
            else if (this.CompareTag("Patsas5"))
            {
                ctrl.activeKivi4();
            }

            normalStone.SetActive(false);
            pressedStone.SetActive(true);

            time = 0f;
        }
    }
示例#3
0
 // Start is called before the first frame update
 void Start()
 {
     Character           = (GameObject)Instantiate(CharacterPrefab);
     CharacterController = Character.GetComponent <MainCharacterController>();
     CharacterController.GenerateCharacterStats();
     GenerateGrid();
 }
示例#4
0
    void Start()
    {
        playerObj        = GameObject.FindGameObjectWithTag("Player");
        playerController = playerObj.GetComponent <MainCharacterController>();

        timeLeft = totalTime;
    }
 void Start()
 {
     medrash = GameObject.FindGameObjectWithTag("Player");
     controller = medrash.GetComponent<MainCharacterController>();
     StartCoroutine(FlameUpdate());
     GetComponent<AudioSource>().volume = flameVolume;
 }
    // Use this for initialization
    void Start()
    {
        this.mainCharacterController = this.mainCharacterGameObject.GetComponent <MainCharacterController>();

        var textObj = GameObject.Find("InstructionsText");

        if (textObj != null)
        {
            textObj.GetComponent <Text>().text =
                "Instructions\n\n" +
                this.mainCharacterController.blendedKey + " - Blended\n" +
                this.mainCharacterController.priorityKey + " - Priority\n" +
                this.mainCharacterController.stopKey + " - Stop";
        }


        var obstacles = GameObject.FindGameObjectsWithTag("Obstacle");

        this.characterControllers = this.CloneCharacters(this.mainCharacterGameObject, 10, obstacles);
        this.characterControllers.Add(this.mainCharacterGameObject.GetComponent <MainCharacterController>());

        //LINQ expression with a lambda function, returns an array with the DynamicCharacter for each character controler
        var characters = this.characterControllers.Select(cc => cc.character).ToList();

        //add the character corresponding to the main character
        //characters.Add(this.mainCharacterController.character);

        //initialize all characters
        foreach (var characterController in this.characterControllers)
        {
            characterController.InitializeMovement(obstacles, characters);
        }
    }
示例#7
0
文件: Player.cs 项目: albpb2/Treeia
    protected override void Awake()
    {
        base.Awake();

        _gun = GetComponentInChildren <MainCharacterGun>();
        _mainCharacterController  = GetComponentInChildren <MainCharacterController>();
        SceneManager.sceneLoaded += HandleSceneLoaded;
    }
示例#8
0
 public void UnproxyPlayer()
 {
     m_PlayerOnBoard.transform.SetParent(null);
     m_PlayerOnBoard = null;
     enabled         = false;
     m_BuoyantObject.velocityDrag = m_InitialVelocityDrag;
     m_BuoyantObject.m_Gravity    = m_InitialGravity;
 }
示例#9
0
    void Start()
    {
        GameObject player = GameObject.FindGameObjectsWithTag("Player")[0];
        mainCharacterController = player.GetComponent<MainCharacterController>();

        var highScoreText = GameObject.FindGameObjectsWithTag("HighScore")[0];
        highScoreText.GetComponent<Text>().text = "High Score " + GetHighScore();
    }
 void Awake()
 {
     if (_mainCtrl != null)
     {
         Destroy(this.gameObject);
     }
     _mainCtrl  = this;
     skinActive = PlayerPrefs.GetInt("skinActive");
 }
示例#11
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        MainCharacterController controller = collision.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            UIController.Instance.OpenForestEntryMenu();
        }
    }
示例#12
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        MainCharacterController controller = collision.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            ForestCanvasController.Instance.BackToHome();
        }
    }
示例#13
0
    // Start is called before the first frame update
    void Start()
    {
        playerData              = GetComponent <PlayerData>();
        gameManager             = GetComponent <GameManager>();
        mainCharacterAnimator   = GetComponent <Animator>();
        mainCharacterController = GetComponent <MainCharacterController>();

        topHeartUIButtons.SetActive(false);    //turns off hearts
        topGoldHomeUIButtons.SetActive(false); //turns off gold home button
    }
示例#14
0
    void OnTriggerExit2D(Collider2D other)
    {
        /* Sets conversation active when Player meets collider. */

        player = other.GetComponent <MainCharacterController>();

        if (player != null)
        {
            active = true;
        }
    }
示例#15
0
    public void Init(int StageNumber, List <Skill> unlockedSkills, List <Skill> AllSkills, MainCharacterController MainControl, int upgrades)
    {
        maincont = MainControl;
        GlobalVariables.Instance.HasUI = true;
        if (StageNumber <= XMLLoad.Instance.stageList.stage.Count)
        {
            StageCompleteText.text = "Stage " + StageNumber + " Completed";
        }
        else
        {
            StageCompleteText.text = "Endless Stage " + (StageNumber - XMLLoad.Instance.stageList.stage.Count) + " Complete";
        }

        SkillsUnlocked = new List <Skill>();
        SkillsUnlocked = unlockedSkills;

        if (unlockedSkills.Count < 1)
        {
            SkillUnlocked.SetActive(false);
        }
        else
        {
            SkillUnlockLeftButton.SetActive(false);
            SkillUnlockRightButton.SetActive(false);
            SkillUnlocked.SetActive(true);
            DisplaySkill(unlockedSkills[0]);
            if (unlockedSkills.Count > 1)
            {
                SkillUnlockedText.text = SkillsUnlocked.Count + " New Skills Unlocked!";
                SkillUnlockRightButton.SetActive(true);
            }
            else
            {
                SkillUnlockedText.text = "New Skill Unlocked!";
            }
        }

        NewMaxHealth.text = "Max Health: " + (100 + 10 * (StageNumber));
        NewStamRegen.text = (10 + 1 * (StageNumber)) + " Stamina/Second";

        UpgradesAvailable.text = "Upgrades Avaialble: " + upgrades;

        if (StageNumber == 1)
        {
            SkillSwapButton.gameObject.SetActive(false);
        }
        else
        {
            SkillSwapButton.gameObject.SetActive(true);
        }
        SkillSwapOverlay.Init(maincont, maincont.GetSlottedSkills(), AllSkills);

        CurrentSkillIndex = 0;
    }
示例#16
0
    public void ProxyPlayer(MainCharacterController _mainCharacterController)
    {
        m_PlayerOnBoard = _mainCharacterController;

        m_PlayerOnBoard.transform.SetParent(transform);
        m_PlayerOnBoard.transform.localPosition = Vector3.zero;
        m_PlayerOnBoard.transform.localRotation = Quaternion.identity;

        m_BuoyantObject.m_Gravity = m_Gravity;

        enabled = true;
    }
示例#17
0
    void OnTriggerStay2D(Collider2D other)
    {
        /*
         *  When meeting collider with Player, calls for method changeLayer().
         */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            changeLayer(controller.getPosition(), controller.getLayer());
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        MainCharacterController controller = collision.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            if (controller.Energy < MainCharacterController.MAX_ENERGY)
            {
                controller.ChangeEnergy(energyFill);
                Destroy(gameObject);
            }
        }
    }
示例#19
0
    /// <summary>
    /// coroutine that gets ran when a stage is complete
    /// </summary>
    /// <returns></returns>
    IEnumerator StageClearSequence()
    {
        yield return(new WaitForSeconds(1));

        MainCharacterController cont          = PlayerInstance.GetComponent <MainCharacterController>();
        List <Skill>            unlockedSkill = UnlockSkill(currentStage.UnlockedSkill);

        //level up  stats on player and save stats
        ProgressSave.Instance.LevelUp();

        //unlock skill for player
        for (int i = 0; i < unlockedSkill.Count; i++)
        {
            cont.LearnSkill(unlockedSkill[i]);
        }



        //display stage complete screen
        if (!StageCompleteInstance)
        {
            StageCompleteInstance = Instantiate(StageCompletePrefab, CameraUI.transform);
        }
        else
        {
            StageCompleteInstance.SetActive(true);
        }


        StageCompleteInstance.GetComponent <StageComplete>().Init(stageNumber, unlockedSkill, cont.GetSkillPool(), cont, currentStage.UpgradeRewards);

        //wait for stage complete screen to be closed to move on
        while (StageCompleteInstance.activeSelf)
        {
            yield return(null);
        }
        // upgrades screen
        upgradesLeft = currentStage.UpgradeRewards;
        ShowUpgradeScreen();
        upgradesComplete = false;
        while (!upgradesComplete)
        {
            yield return(null);
        }


        // save upgraded version of skills and equipped slots
        cont.SaveSkills();
        initialized = false;
        Init(ProgressSave.Instance.CurrentLevel); //place holder for next stage, in the future need to implement load scene
    }
示例#20
0
    /// <summary>
    /// shows the upgrade screen overlay
    /// </summary>
    public void ShowUpgradeScreen()
    {
        MainCharacterController cont = PlayerInstance.GetComponent <MainCharacterController>();

        if (!UpgradeScreenInstance)
        {
            UpgradeScreenInstance = Instantiate(UpgradeScreenPrefab, CameraUI.transform);
        }
        else
        {
            UpgradeScreenInstance.SetActive(true);
        }
        UpgradeScreenInstance.GetComponent <UpgradeController>().Init(cont.GetSkillsWithUpgrades(), cont.GetSlottedSkills(), upgradesLeft, this);
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        /* When Player meets collider, calls for MainCharacterController method ChangeHealth().
         * Destroys HealthObject.
         */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            controller.ChangeHealth(health);
            Destroy(gameObject);
        }
    }
示例#22
0
    private void Start()
    {
        coinTextBox.SetActive(false);

        mainCharInv      = MainCharInventory.Instance;
        hotbarCont       = HotbarController.Instance;
        dialogCont       = DialogController.Instance;
        storeCont        = WebStoreController.Instance;
        mainCharCont     = MainCharacterController.Instance;
        settingsCont     = SettingsController.Instance;
        nightCont        = NightController.Instance;
        forestCanvasCont = ForestCanvasController.Instance;
        timeSystem       = TimeSystem.Instance;
        endGameCont      = EndGameController.Instance;
    }
示例#23
0
    void TrackCameraModify()
    {
        // to fix bug with weird moving when scaling
        LeanScale scale = ParentAR.GetComponent <LeanScale>();

        if (scale != null)
        {
            MainCharacterController character = MainCharacter.GetComponent <MainCharacterController>();
            if (character == null)
            {
                return;
            }

            character.StopMoving = scale.IsCameraModify;
        }
    }
示例#24
0
    public void Load(int saveSlot)
    {
        if (saveSlot == 1 || saveSlot == 2 || saveSlot == 3)
        {
            MainCharacterController mc = MainCharacterController.Instance;
            JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString(SAVE_KEY + saveSlot.ToString()), this);

            mc.Money = currentMoney;
            TimeSystem.Instance.UpdateDay(day);

            EmptyFields();
        }
        else
        {
            Debug.Log("Save slot is invalid!");
        }
    }
示例#25
0
    public void LoadSaveSlotData(SaveSlot slot)
    {
        if (slot.saveSlot == 1 || slot.saveSlot == 2 || slot.saveSlot == 3)
        {
            MainCharacterController mc = MainCharacterController.Instance;

            JsonUtility.FromJsonOverwrite(PlayerPrefs.GetString(SAVE_KEY + slot.saveSlot.ToString()), this);

            slot.SetCoins(currentMoney.ToString());
            slot.SetDays(day.ToString());
            slot.SetSaveName(saveName);

            EmptyFields();
        }
        else
        {
            Debug.Log("Save slot is invalid!");
        }
    }
示例#26
0
    public void Save(int saveSlot, string sName)
    {
        if (saveSlot == 1 || saveSlot == 2 || saveSlot == 3)
        {
            MainCharacterController mc = MainCharacterController.Instance;
            currentMoney = mc.Money;
            saveName     = sName;
            day          = TimeSystem.Instance.day;

            string jsonData = JsonUtility.ToJson(this);
            PlayerPrefs.SetString(SAVE_KEY + saveSlot.ToString(), jsonData);
            PlayerPrefs.Save();

            EmptyFields();
        }
        else
        {
            Debug.Log("Save slot is invalid!");
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        /* When Player meets the collider, steps will be moving forward.
         * Steps cannot move backwards.
         */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            position = stepper.position;
            Vector2 temp = position;
            position.y = position.y + speed * vertical;

            if (position.y > temp.y)
            {
                next = true;
            }
        }
    }
示例#28
0
 public void Init(MainCharacterController Maincont, List <Skill> SlottedSkills, List <Skill> AllSkills)
 {
     foreach (GameObject g in currentSlots)
     {
         Destroy(g);
     }
     currentSlots  = new List <GameObject>();
     SlotPrefab    = Resources.Load("Prefabs/UI/Overlays/SlotOption") as GameObject;
     maincont      = Maincont;
     slottedSkills = SlottedSkills;
     allSkills     = AllSkills;
     for (int i = 0; i < slotLocations.Count; i++)
     {
         var instance = Instantiate(SlotPrefab, transform);
         currentSlots.Add(instance);
         instance.transform.position = slotLocations[i].position;
         instance.GetComponent <SlotOption>().Init(slottedSkills[i], i);
         instance.GetComponent <SlotOption>().onChosen.AddListener(SelectSlot);
     }
 }
示例#29
0
    private void StartDay()
    {
        currentHours = DAY_START_HOURS;
        currentMins  = 0;
        day++;

        MainCharacterController mc = MainCharacterController.Instance;

        if (SceneManager.GetActiveScene().name.Equals("FarmScene"))
        {
            mc.gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
            mc.MoveToStartPosition();
            FarmingController.Instance.AgePlants();

            SaveLoadSystem.Instance.SaveProgress();
        }
        else
        {
            SaveLoadSystem.Instance.SaveTempProgress();
        }
    }
    void OnTriggerStay2D(Collider2D other)
    {
        /* Collider launches the change when C is pressed within the collider. */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null && Input.GetKey("c"))
        {
            Debug.Log("C pressed");

            if (normal.active == true)
            {
                /* Normal sprite is deactivated and Changed sprite is activated. Using this, costs player health. */

                Debug.Log("Lohko 1");
                normal.SetActive(false);
                changed.SetActive(true);

                controller.ChangeHealth(-1);
            }
        }
    }
示例#31
0
    void OnTriggerEnter2D(Collider2D other)
    {
        /* When Player meets the collider, movingObject will be moving desired direction. */

        MainCharacterController controller = other.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            Vector2 position       = rigidbody2d.position;
            Vector2 targetPosition = position;
            targetPosition.x = position.x + speed * horizontal;
            targetPosition.y = position.y + speed * vertical;

            float res = 0f;

            if (x)
            {
                res = count.countDiversition(goalPosition, targetPosition.x);
            }
            else
            {
                res = count.countDiversition(goalPosition, targetPosition.y);
            }

            RaycastHit2D raycast = Physics2D.Raycast(position, targetPosition, 1);
            if (raycast.collider != null && raycast.collider.CompareTag("Wall"))
            {
                Debug.Log("Wall.");
            }
            else if (res < temp)
            {
                temp = res;
                rigidbody2d.MovePosition(targetPosition);
                ctrl.savePosition(this.tag, targetPosition);
            }
        }
    }
示例#32
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        /* When player meets collider, checks which bool is true.
         * Bool determines destination.
         */

        MainCharacterController controller = collision.GetComponent <MainCharacterController>();

        if (controller != null)
        {
            if (nextGarden)
            {
                Loader.Load(Loader.Scene.GardenScene);
            }
            else if (nextMachine)
            {
                Loader.Load(Loader.Scene.Konehuone);
            }
            else if (nextMusic)
            {
                Loader.Load(Loader.Scene.Musiikkihuone);
            }
        }
    }
示例#33
0
 // Use this for initialization
 void Start()
 {
     runningEnemy = null;
     medrash = GameObject.FindGameObjectWithTag("Player").GetComponent<MainCharacterController>();
 }
 void Start()
 {
     scene = Scene.Scene01;
     primaryBar = GetComponent<PrimaryBar>();
     secondaryBar = GetComponent<SecondaryBar>();
     characterController = GetComponent<MainCharacterController>();
     if (scene.Equals(Scene.Scene01))
     {
         secondaryBar.HasBar = true;
         secondaryBar.setopcao(2);
         StartCoroutine(CheckCharacterPhysicalCondition());
     }
     else if (scene.Equals(Scene.Scene02))
     {
         GrabTorch();
         secondaryBar.HasBar = true;
         secondaryBar.setopcao(1);
         StartCoroutine(CheckCharacterBodyTemperature());
     }
     else
     {
         secondaryBar.HasBar = false;
     }
     object[] obj = GameObject.FindObjectsOfType(typeof(Entity));
     foreach (object o in obj) {
         Entity e = (Entity) o;
         e.SetMainCharacter(this.gameObject);
         listOfEnemies.Add(e);
         e.enabled = true;
     }
 }
 void Start()
 {
     Time.timeScale = 1;
     primaryBar = GetComponent<PrimaryBar>();
     secondaryBar = GetComponent<SecondaryBar>();
     characterController = GetComponent<MainCharacterController>();
     secondaryBar.HasBar = true;
     secondaryBar.setopcao(2);
     StartCoroutine(CheckCharacterPhysicalCondition());
     object[] obj = GameObject.FindObjectsOfType(typeof(Entity));
     foreach (object o in obj) {
         Entity e = (Entity) o;
         e.SetMainCharacter(this.gameObject);
         listOfEnemies.Add(e);
     }
     myScore = GetComponent<Score>();
     myScore.SetScore(0);
     StartCoroutine(ActivateEnemies());
 }
    void Awake()
    {
        if (Camera.main) cameraTransform = Camera.main.transform;

        if (!cameraTransform)
        {
            Debug.Log("Please assign a camera to the ThirdPersonCamera script.");
            enabled = false;
        }
        target = transform;
        if (target)
        {
            controller = target.GetComponent<MainCharacterController>();
        }

        if (controller)
        {
            CharacterController characterController = (CharacterController) target.GetComponent("CharacterController");
            centerOffset = characterController.bounds.center - target.position;
            headOffset = centerOffset;
            headOffset.y = characterController.bounds.max.y - target.position.y;
        }
        else
        {
            Debug.Log("Please assign a target to the camera that has a ThirdPersonController script attached.");
        }
        Cut(target, centerOffset);
    }