Esempio n. 1
0
        void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
        {
            if (currentController.currentHealth > 0)
            {
                return;
            }

            OnReloadGame.Invoke();

            var player = GameObject.FindObjectOfType <vThirdPersonController>();

            if (player)
            {
                currentPlayer     = player.gameObject;
                currentController = player;
                player.onDead.AddListener(OnCharacterDead);
            }
            else if (currentPlayer == null && playerPrefab != null && spawnPoint != null)
            {
                Spawn(spawnPoint);
            }
        }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        modoExploracao = FindObjectOfType(typeof(ModoExploracao)) as ModoExploracao;
        tutorialGeral  = FindObjectOfType(typeof(TutorialGeral)) as TutorialGeral;
        loading        = FindObjectOfType(typeof(Loading)) as Loading;

        inputs = FindObjectOfType(typeof(vThirdPersonController)) as vThirdPersonController;

        pecas          = FindObjectOfType(typeof(Pecas)) as Pecas;
        gameController = FindObjectOfType(typeof(GameController)) as GameController;

        colidiuPlayer = FindObjectOfType(typeof(ColidiuPlayer)) as ColidiuPlayer;

        cena = SceneManager.GetActiveScene();
        barraPorcentagem.SetActive(false);
        thirPerson = FindObjectOfType(typeof(vThirdPersonMotor)) as vThirdPersonMotor;
        for (int i = 0; i < img_Engrenagens.Length; i++)
        {
            cor[i] = img_Engrenagens[i].color;
        }
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
Esempio n. 3
0
        public IEnumerator Spawn()
        {
            yield return(new WaitForSeconds(respawnTimer));

            if (playerPrefab != null && spawnPoint != null)
            {
                if (oldPlayer != null && destroyBodyAfterDead)
                {
                    if (displayInfoInFadeText && vHUDController.instance)
                    {
                        vHUDController.instance.ShowText("Player destroyed: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
                    }
                    Destroy(oldPlayer);
                }

                else
                {
                    if (displayInfoInFadeText && vHUDController.instance)
                    {
                        vHUDController.instance.ShowText("Remove Player Components: " + oldPlayer.name.Replace("(Clone)", "").Replace("Instance", ""));
                    }
                    DestroyPlayerComponents(oldPlayer);
                }

                yield return(new WaitForEndOfFrame());

                currentPlayer     = Instantiate(playerPrefab, spawnPoint.position, spawnPoint.rotation) as GameObject;
                currentController = currentPlayer.GetComponent <vThirdPersonController>();
                currentController.onDead.AddListener(OnCharacterDead);

                if (displayInfoInFadeText && vHUDController.instance)
                {
                    vHUDController.instance.ShowText("Respawn player: " + currentPlayer.name.Replace("(Clone)", ""));
                }
                OnReloadGame.Invoke();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Finds your player and populates internal variables so the chatbox
 /// can enable or disable various aspects of your character when the
 /// box is open or closed.
 /// </summary>
 protected virtual void SetMyPlayer()
 {
     foreach (vThirdPersonController controller in FindObjectsOfType <vThirdPersonController>())
     {
         if (controller.gameObject.GetComponent <PhotonView>().IsMine == true)
         {
             player = controller;
             if (player.GetComponent <vMeleeCombatInput>())
             {
                 meleeInput = player.GetComponent <vMeleeCombatInput>();
             }
             if (player.GetComponent <vInventory>())
             {
                 playerInventory = player.GetComponent <vInventory>();
             }
             if (!playerInventory && player.GetComponent <vItemManager>())
             {
                 playerInventory = player.GetComponent <vItemManager>().inventory;
             }
             break;
         }
     }
     orgCursorMode = Cursor.lockState;
 }
Esempio n. 5
0
        private void Start()
        {
            // first we need to access our itemManager from the Controller
            if (itemManager == null)
            {
                //check 'getInParent' if this script is attached to a children of the itemManager
                if (getInParent)
                {
                    itemManager = GetComponentInParent <vItemManager>();
                }
                else
                {
                    itemManager = GetComponent <vItemManager>();
                }
            }

            // now we access the Controller itself to know the currentHealth later
            if (tpController == null)
            {
                if (getInParent)
                {
                    tpController = GetComponentInParent <vThirdPersonController>();
                }
                else
                {
                    tpController = GetComponent <vThirdPersonController>();
                }
            }

            // if a itemManager is founded, we use this event to call our CanUseItem method
            if (itemManager)
            {
                itemManager.canUseItemDelegate -= new vItemManager.CanUseItemDelegate(CanUseItem);
                itemManager.canUseItemDelegate += new vItemManager.CanUseItemDelegate(CanUseItem);
            }
        }
Esempio n. 6
0
        public IEnumerator Spawn()
        {
            yield return(new WaitForSeconds(respawnTimer));

            if (playerPrefab != null && spawnPoint != null)
            {
                if (oldPlayer != null && destroyBodyAfterDead)
                {
                    Destroy(oldPlayer);
                }
                else
                {
                    DestroyPlayerComponents(oldPlayer);
                }

                yield return(new WaitForEndOfFrame());

                currentPlayer     = Instantiate(playerPrefab, spawnPoint.position, spawnPoint.rotation) as GameObject;
                currentController = currentPlayer.GetComponent <vThirdPersonController>();
                currentController.onDead.AddListener(OnCharacterDead);

                OnReloadGame.Invoke();
            }
        }
Esempio n. 7
0
 public void Start()
 {
     Player = FindObjectOfType <vThirdPersonController>();
     Camera = FindObjectOfType <vThirdPersonCamera>();
     isDead = false;
 }
Esempio n. 8
0
 // Start is called before the first frame update
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     cc     = player.GetComponent <vThirdPersonController>();
 }
Esempio n. 9
0
        /// <summary>
        /// Create button event, adds all components.
        /// </summary>
        void Create()
        {
            if (Selection.activeGameObject != null)
            {  // fail safe
                // add melee manager for when shooter
                if (!Selection.activeGameObject.GetComponent <vMeleeManager>())
                {
                    Selection.activeGameObject.AddComponent <vMeleeManager>();
                }

                // inventory
                vItemManager itemManager = Selection.activeGameObject.GetComponent <vItemManager>();
                if (!itemManager)
                {
                    itemManager = Selection.activeGameObject.AddComponent <vItemManager>();
                    vItemManagerUtilities.CreateDefaultEquipPoints(itemManager, itemManager.GetComponent <vMeleeManager>());
                }
                itemManager.inventoryPrefab = InventoryPrefab;
                itemManager.itemListData    = ItemListData;
                itemManager.itemsFilter.Add(vItemType.MeleeWeapon);
                itemManager.itemsFilter.Add(vItemType.Spell);

                // hit damage particle
                vHitDamageParticle hitDamageParticle = Selection.activeGameObject.GetComponent <vHitDamageParticle>();
                if (!hitDamageParticle)
                {
                    hitDamageParticle = Selection.activeGameObject.AddComponent <vHitDamageParticle>();
                }
                hitDamageParticle.defaultDamageEffect = HitDamageParticle;

                // UI
                GameObject goItemCollectionDisplay = PrefabUtility.InstantiatePrefab(ItemCollectionDisplay) as GameObject;
                goItemCollectionDisplay.transform.SetParent(UIBase.transform);
                GameObject goInventoryPrefab = PrefabUtility.InstantiatePrefab(InventoryPrefab.gameObject) as GameObject;
                goInventoryPrefab.name = "Inventory_MeleeMagic_Auto";


                // leveling system
                CharacterInstance levelingsystem = Selection.activeGameObject.GetComponent <CharacterInstance>();
                if (!levelingsystem)
                {
                    levelingsystem = Selection.activeGameObject.AddComponent <CharacterInstance>();
                }

                // link the invector character damage event to the leveling system
                vThirdPersonController thirdp = Selection.activeGameObject.GetComponent <vThirdPersonController>();
                UnityEventTools.AddPersistentListener(thirdp.onReceiveDamage, levelingsystem.OnRecieveDamage);

                // link the melee manager hits to the leveling system
                vMeleeManager meleeM = Selection.activeGameObject.GetComponent <vMeleeManager>();
                if (meleeM)
                {
                    if (meleeM.onDamageHit == null)
                    {
                        meleeM.onDamageHit = new vOnHitEvent();
                    }
                    UnityEventTools.AddPersistentListener(meleeM.onDamageHit, levelingsystem.OnSendHit);
                }

                // add conditions and update particles to use the LOD 1 mesh
                levelingsystem.Conditions = new List <BaseCondition>();
                levelingsystem.Conditions.Add(new BaseCondition()
                {
                    Type = BaseDamage.Physical
                });
                GameObject goConditionsRoot = new GameObject("Conditions");
                goConditionsRoot.transform.SetParent(Selection.activeGameObject.transform);
                goConditionsRoot.transform.position = new Vector3(0f, 0f, 0f);
                foreach (BaseCondition bc in Conditions)
                {
                    GameObject goCondition = null;
                    if (bc.Display)
                    {
                        // load the prefab
                        goCondition = PrefabUtility.InstantiatePrefab(bc.Display) as GameObject;
                        goCondition.transform.SetParent(goConditionsRoot.transform);
                        goCondition.transform.position = new Vector3(0f, 0f, 0f);

                        // update all particles to use the mesh renderer from LOD1
                        goCondition.SetActive(true);
                        ParticleSystem[] ConditionParticles = goCondition.GetComponentsInChildren <ParticleSystem>();
                        foreach (ParticleSystem p in ConditionParticles)
                        {
                            if (p.shape.enabled)
                            {
                                if (p.shape.shapeType == ParticleSystemShapeType.SkinnedMeshRenderer)
                                {
                                    ParticleSystem.ShapeModule editableShape = p.shape;
                                    editableShape.skinnedMeshRenderer = LOD1BodyMesh[iWhichMesh];
                                }
                            }
                        }
                        goCondition.SetActive(false);
                    }

                    // add to the levelling system
                    levelingsystem.Conditions.Add(new BaseCondition()
                    {
                        Type = bc.Type, Length = 0, Display = goCondition
                    });
                }

                // add the magic spawn point
                GameObject goMagicSpawn = new GameObject("Magic Spawn");
                goMagicSpawn.transform.SetParent(Selection.activeGameObject.transform);
                goMagicSpawn.transform.position = new Vector3(0f, 1.5f, 0.9f);

                // magic input
                MagicSettings magicIO = Selection.activeGameObject.GetComponent <MagicSettings>();
                if (!magicIO)
                {
                    magicIO = Selection.activeGameObject.AddComponent <MagicSettings>();
                }
                magicIO.PooledMagic     = true;
                magicIO.MagicSpawnPoint = goMagicSpawn.transform;
                magicIO.onUseMana       = new UnityIntEvent();
                UnityEventTools.AddPersistentListener(magicIO.onUseMana, levelingsystem.UseMana);


#if !VANILLA                                                                                                         // set spell triggers F1-F5
                GameObject goInventoryWindow    = goInventoryPrefab.transform.Find("InventoryWindow").gameObject;    // grab inventory window
                GameObject goEquipmentInventory = goInventoryWindow.transform.Find("EquipmentInventory").gameObject; // and the equip slot parent
                goEquipmentInventory.SetActive(true);                                                                // enable for component search
                int          iNext    = 1;
                vEquipSlot[] allSlots = goInventoryPrefab.GetComponentsInChildren <vEquipSlot>();
                foreach (vEquipSlot slot in allSlots)
                {
                    if (slot.transform.parent.parent.name == "EquipMentArea_Spells")
                    {                                                                                                      // is a spell inventory area
                        MagicSpellTrigger trigger = new MagicSpellTrigger();                                               // create the trigger
                        trigger.EquipSlots     = new vEquipSlot[] { slot };                                                // set the inventory slot
                        trigger.Input          = new GenericInput("F" + iNext.ToString(), null, null);                     // set the input key
                        trigger.Input.useInput = true;                                                                     // enable
                        vEquipmentDisplay[] allDisplays = goInventoryPrefab.GetComponentsInChildren <vEquipmentDisplay>(); // find all displays
                        foreach (vEquipmentDisplay disp in allDisplays)
                        {                                                                                                  // check all
                            if (disp.gameObject.name == slot.gameObject.name.Replace("EquipSlot ", "EquipDisplay_Spell "))
                            {                                                                                              // found matching name?
                                trigger.EquipDisplay = disp;                                                               // success, apply
                                UnityEventTools.AddPersistentListener(slot.onAddItem, magicIO.SpellEquiped);               // listen for spells equiped
                                UnityEventTools.AddPersistentListener(slot.onRemoveItem, magicIO.SpellUnEquiped);          // and unequiped
                                break;                                                                                     // drop out
                            }
                        }
                        magicIO.SpellsTriggers.Add(trigger); // add the trigger
                        iNext += 1;                          // next please
                    }
                }
                goEquipmentInventory.SetActive(false);  // deactivate the inventory display
#endif

                // link the UI further
                Transform tHUD = UIBase.transform.Find("HUD");
                magicIO.XPText      = tHUD.Find("XP").GetComponent <UnityEngine.UI.Text>();
                magicIO.LevelText   = tHUD.Find("Level").GetComponent <UnityEngine.UI.Text>();
                magicIO.LevelUpText = tHUD.Find("Level up").GetComponent <UnityEngine.UI.Text>();
                magicIO.ManaSlider  = tHUD.Find("mana").GetComponent <UnityEngine.UI.Slider>();

#if !VANILLA
                itemManager.onUseItem = new OnHandleItemEvent();
                UnityEventTools.AddPersistentListener(itemManager.onUseItem, magicIO.UsePotion);

                // also lock input when inventory open
                itemManager.onOpenCloseInventory = new OnOpenCloseInventory();
                vMeleeCombatInput MeleeInput = Selection.activeGameObject.GetComponent <vMeleeCombatInput>();
                if (MeleeInput)
                {
                    UnityEventTools.AddPersistentListener(itemManager.onOpenCloseInventory, MeleeInput.SetLockMeleeInput);
                }
#endif
                // work complete
                this.Close();
            }
            else
            {
                Debug.Log("Please select the Player to add these components.");
            }
        }
Esempio n. 10
0
 // Start is called before the first frame update
 private void Awake()
 {
     cc = gameObject.GetComponent <vThirdPersonController>();
 }
Esempio n. 11
0
 private void Awake()
 {
     Motor = GetComponent <vThirdPersonController>();
     GM    = GameSceneManager.Instance;
 }
Esempio n. 12
0
 public void Init(vThirdPersonController cc)
 {
     cc.onDead.AddListener(OnDead);
     cc.onReceiveDamage.AddListener(EnableDamageSprite);
     damageImage.color = new Color(0f, 0f, 0f, 0f);
 }
Esempio n. 13
0
 void Start()
 {
     rb         = this.GetComponent <Rigidbody>();
     controller = this.GetComponent <vThirdPersonController>();
     callCount  = 2;
 }
Esempio n. 14
0
 // Start is called before the first frame update
 void Start()
 {
     cc                 = gameObject.GetComponent <vThirdPersonController>();
     kiipeäminen        = gameObject.GetComponent <Kiipeäminen>();
     lastGroundHitPoint = transform.position;
 }
 // For Storing player position in scene while jumping between World Scene and Battle scene
 public void SaveData(vThirdPersonController playerController) // vThirdPersonController is a free asset we used from AssetStore
 {
     PlayerPrefs.SetFloat("x", playerController.transform.position.x);
     PlayerPrefs.SetFloat("y", playerController.transform.position.y);
     PlayerPrefs.SetFloat("z", playerController.transform.position.z);
 }
Esempio n. 16
0
 void Init()
 {
     cc    = GetComponent <vThirdPersonController>();
     timer = GetComponent <Timer>();
     Spawn();
 }
Esempio n. 17
0
    // Update is called once per frame
    void Update()
    {
        if (on == true)
        {
            trapText2.enabled = true;
            vThirdPersonInput vt = gameObject.GetComponentInParent <vThirdPersonInput>();

            vt.enabled = false;
            vThirdPersonController vc = gameObject.GetComponentInParent <vThirdPersonController>();
            vc.enabled = false;

            GameObject.Find("male").transform.position = charForm;


            onTime = onTime + Time.deltaTime;
            if (onTime > 2.0f)
            {
                GameObject bullet = Instantiate(bulletPre, transform.position, transform.rotation);
                bullet.GetComponent <Rigidbody>().AddForce(transform.forward * 10.0f);
                on     = false;
                onTime = 0.0f;
                GameObject.Find("male").transform.position = charForm;
                vt.enabled        = true;
                vc.enabled        = true;
                trapText2.enabled = false;
                bulletOn          = false;
                bulletReroad      = false;
            }
        }

        if (trapText.enabled == true)
        {
            textTime = textTime + Time.deltaTime;

            if (textTime >= 3.0f)
            {
                trapText.enabled = false;
                textTime         = 0;
            }
        }

        if (bulletReroad == false)
        {
            bulletTime = bulletTime + Time.deltaTime;


            if (bulletTime >= 2.0f)
            {
                bulletReroad = true;
                bulletTime   = 0;
            }
        }


        if (Input.GetButtonDown("Fire1") && bulletReroad == true && bulletOn == true)
        {
            charForm = GameObject.Find("male").gameObject.transform.position;

            on = true;
        }

        if (count == 3)
        {
            GameObject.Find("blackgo").GetComponent <Image>().enabled     = true;
            GameObject.Find("blackgo").GetComponent <Imageskip>().enabled = true;
        }
    }
Esempio n. 18
0
 // Use this for initialization
 void Start()
 {
     m_input = GetComponent <vThirdPersonInput>();
     m_move  = GetComponent <vThirdPersonController>();
 }
Esempio n. 19
0
    private void OnTriggerEnter(Collider other)
    {
        GameObject player = other.gameObject;

        if (player.layer == 10)
        {
            PinballMotion             pinball_player = player.GetComponent <PinballMotion>();
            ThirdPersonControllerDash dash_player    = player.GetComponent <ThirdPersonControllerDash>();
            Rigidbody              rb                = player.GetComponent <Rigidbody>();
            vThirdPersonInput      input_player      = player.GetComponent <vThirdPersonInput>();
            vThirdPersonController controller        = player.GetComponent <vThirdPersonController>();
            vThirdPersonCamera     camera_controller = Camera.main.GetComponent <vThirdPersonCamera>();

            if (Tipologia == pathElement.endpoint)
            {
                controller.isJumping   = false;
                controller.isGrounded  = true;
                pinball_player.enabled = false;
                dash_player.enabled    = true;
                input_player.enabled   = true;
                controller.UpdateAnimator();
                pinball_player.direction = Vector3.zero;
                percorso.SetActive(true);
                if (mirroredVersion)
                {
                    percorso.transform.rotation = Quaternion.Euler(Vector3.zero);
                }
                else
                {
                    percorso.transform.rotation = Quaternion.Euler(Vector3.up * 180);
                }
            }
            else
            {
                if (Tipologia == pathElement.start)
                {
                    controller.isJumping   = true;
                    controller.isGrounded  = false;
                    pinball_player.enabled = true;
                    dash_player.enabled    = false;
                    input_player.enabled   = false;
                    controller.animator.CrossFadeInFixedTime("JumpMove", .2f);
                    controller.UpdateAnimator();
                    Vector3 directionTarget = target.transform.position - player.transform.position;
                    directionTarget.y = 0;
                    directionTarget   = directionTarget.normalized;
                    float angle = Mathf.Atan2(directionTarget.x, directionTarget.z) * 180 / Mathf.PI;
                    pinball_player.direction = directionTarget;
                    rb.transform.forward     = directionTarget;
                    camera_controller.SetMouseX(angle);
                    camera_controller.SetMouseY(0.0f);
                    this.GetComponent <PinballSounds>().PlaySound();
                }
                else
                {
                    Triggerabile.GetComponent <EstensioneMolla>().state = 1;
                    Triggerabile.GetComponent <PinballSounds>().PlaySound();
                    pinball_player.direction = Vector3.down * 0.00001f;
                }
            }
        }
    }