Inheritance: MonoBehaviour
Esempio n. 1
0
    void Awake()
    {
        Instance = this;

        if (rb == null)
        {
            rb = GetComponent <Rigidbody>();
        }

        NavMeshAgent agent = GetComponent <NavMeshAgent>();

        if (agent != null)
        {
            agent.updateRotation = false;
            agent.updatePosition = false;
        }

        StartAcc      = characceleration;
        StartMaxSpeed = maxSpeed;

        if (_impulse)
        {
            _acceleration = false;
        }
        else if (_acceleration)
        {
            _impulse = false;
        }
        else
        {
            _impulse = true;
        }
    }
Esempio n. 2
0
    public static void ShowCollect()
    {
        Int_Intern_Collect.SetActive(true);
        Int_Intern_Options.SetActive(true);
        Int_Intern_Desc.SetActive(false);

        TextMeshProUGUI o1 = Int_Intern_OptionA.GetComponent <TextMeshProUGUI>();
        TextMeshProUGUI o2 = Int_Intern_OptionB.GetComponent <TextMeshProUGUI>();
        TextMeshProUGUI o3 = Int_Intern_OptionC.GetComponent <TextMeshProUGUI>();

        Image i = Int_Intern_Image.GetComponent <Image>();

        if (i != null)
        {
            i.sprite = CharControl.GetLastCard().CardImage;
        }

        if (o1 != null)
        {
            o1.text = CharControl.GetLastCard().Word1;
        }
        if (o2 != null)
        {
            o2.text = CharControl.GetLastCard().Word2;
        }
        if (o3 != null)
        {
            o3.text = CharControl.GetLastCard().Word3;
        }

        selected = CharControl.GetLastCard();

        GameState = 1;
    }
Esempio n. 3
0
    void EventAttack()
    {
        Vector3 center = transform.TransformPoint(m_attackOffset);
        float   radius = m_attackRadius;


        Debug.DrawRay(center, transform.forward, Color.red, 0.5f);

        Collider[] cols = Physics.OverlapSphere(center, radius);

        foreach (Collider col in cols)
        {
            CharControl charControl = col.GetComponent <CharControl>();
            if (charControl == null)
            {
                continue;
            }

            if (charControl == this)
            {
                continue;
            }

            charControl.TakeDamage(this, center, transform.forward, 1.0f);
        }
    }
Esempio n. 4
0
    void CheckHit()
    {
        Collider[] cols = Physics.OverlapSphere(transform.position, m_hitRadius);

        foreach (Collider col in cols)
        {
            if (col.isTrigger == true)
            {
                continue;
            }

            CharControl charControl = col.GetComponent <CharControl>();
            if (charControl == null)
            {
                m_moveStop = true;
                return;
            }

            if (charControl.gameObject == m_owner)
            {
                continue;
            }

            charControl.TakeDamage(null, transform.position, m_direction, 1.0f);
            Destroy(gameObject);
            return;
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    private void Update()
    {
        //Left mouse button down
        if (Input.GetMouseButtonDown(0))
        {
            startPosition = UtilsClass.GetMouseWorldPosition();
            selectionAreaTrans.gameObject.SetActive(true);
        }
        //Left mouse button hold
        if (Input.GetMouseButton(0))
        {
            Vector3 currentMousePosition = UtilsClass.GetMouseWorldPosition();
            Vector3 lowerLeft            = new Vector3(
                Mathf.Min(startPosition.x, currentMousePosition.x),
                Mathf.Min(startPosition.y, currentMousePosition.y)
                );
            Vector3 upperRight = new Vector3(
                Mathf.Max(startPosition.x, currentMousePosition.x),
                Mathf.Max(startPosition.y, currentMousePosition.y)
                );

            selectionAreaTrans.position   = lowerLeft;
            selectionAreaTrans.localScale = upperRight - lowerLeft;
        }
        //Left mouse button up
        if (Input.GetMouseButtonUp(0))
        {
            endPostion = UtilsClass.GetMouseWorldPosition();
            selectionAreaTrans.gameObject.SetActive(false);
            collider2DArray = Physics2D.OverlapAreaAll(startPosition, endPostion);
            foreach (CharControl charControl in people)
            {
                charControl.SetSelectedVisible(false);
            }
            people.Clear();
            foreach (Collider2D collider2D in collider2DArray)
            {
                CharControl charControl = collider2D.GetComponent <CharControl>();
                if (charControl != null)
                {
                    charControl.SetSelectedVisible(true);
                    people.Add(charControl);
                }
            }
        }


        // GUI - DEBUG
        uiText1.text = "Start: " + startPosition.ToString();
        uiText2.text = "End: " + endPostion.ToString();

        /*if (collider2DArray != null)
         * {
         *  uiText3.text = "Objects: " + String.Join(",", collider2DArray.ToList());
         * }
         * if (people != null)
         * {
         *  uiText4.text = "People: " + String.Join(",", people);
         * }*/
    }
Esempio n. 6
0
    public void TakeDamage(CharControl other, Vector3 hitPosition, Vector3 hitDirection, float amount)
    {
        //-------------------------
        // Please enter your code.
        // hp calculation
        // animation reaction
        // ...
        //-------------------------

        //----------------------
        // For example
        //----------------------

        //--------------------
        // direction
        if (other != null)
        {
            transform.forward = -other.transform.forward;
        }
        else
        {
            hitDirection.y    = 0.0f;
            transform.forward = -hitDirection.normalized;
        }

        //--------------------
        // animation
        string reaction = m_damageReaction[Random.Range(0, m_damageReaction.Length)];

        m_ani.CrossFade(reaction, 0.1f, 0, 0.0f);

        //--------------------
        // hitFX
        GameObject.Instantiate(m_hitEffect, hitPosition, Quaternion.identity);
    }
Esempio n. 7
0
 void Awake()
 {
     lastStep = 0;
     nextStep = 1;
     lastPos  = Vector2Int.RoundToInt(transform.position);
     nextPos  = lastPos;
     cc       = GetComponent <CharControl>();
     grid     = (GridManager)GameObject.FindObjectOfType(typeof(GridManager));
 }
Esempio n. 8
0
 //Pickup
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name == "CharacterPhysic")
     {
         CharControl.CollectCard(PickUpCard);
         InterfaceM.ShowCollect();
         Destroy(this.gameObject);
     }
 }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     Health         = MaxHealth;
     Player         = GameObject.FindGameObjectWithTag("Player");
     PlayerRb       = GetComponent <Rigidbody> ();
     Controller     = GetComponent <CharControl> ();
     CharController = GetComponent <CharacterController> ();
     Collider       = GetComponent <SphereCollider> ();
     Dead           = false;
 }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        GameObject thePlayer = GameObject.Find("BoyCharacter");

        control = thePlayer.GetComponent <CharControl>();

#if UNITY_EDITOR
        StartCoroutine(InitializeAfterSlightDelay());
#else
        SetupElements();
#endif
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        int        randomArrayChoose = Random.Range(0, 7);
        Quaternion phoneRotate       = Quaternion.Euler(0f, 0f, 180f);

        Instantiate(phonePrefab, phonePositions[randomArrayChoose], phoneRotate);

        GameObject  charController    = GameObject.Find("Player");
        CharControl charControlScript = charController.GetComponent <CharControl> ();

        charControlScript.enabled = false;
    }
Esempio n. 12
0
    void Start()
    {
        airPage.enabled    = false;
        groundPage.enabled = false;
        pauseMenu.SetActive(false);
        controlsPage.SetActive(false);
        loadingScreen.SetActive(false);

        #region Assigning Parameters
        charControlScript = player.GetComponent <CharControl>();
        #endregion
    }
    //public ItemRegistry registeritem;

    public void Awake()
    {
        itemok            = false;
        ranker            = GameObject.Find("Avatar").GetComponent <MilestoneRankManager>();
        storychecker      = GameObject.Find("Avatar").GetComponent <StoryChecker>();
        Pickuptext        = GameObject.Find("Item Pickup").GetComponent <Text>();
        dagear            = GameObject.Find("Avatar").GetComponent <Itemslots>();
        itemchecker       = GameObject.Find("Avatar").GetComponent <AchievementHunter>();
        sfxControlScript  = GameObject.Find("SFXControl").GetComponent <SfxControl>();
        pickedUpNameText  = GameObject.Find("PickedUpText").GetComponent <Text>();
        PickupImage       = GameObject.Find("PickUp").GetComponent <Image>();//update
        charControlScript = GameObject.Find("Avatar").GetComponent <CharControl>();
    }
Esempio n. 14
0
    void Update()
    {
        GameObject  charController    = GameObject.Find("Player");
        CharControl charControlScript = charController.GetComponent <CharControl> ();
        GameObject  gameTimer         = GameObject.Find("Timer");
        TimerScript timeScript        = gameTimer.GetComponent <TimerScript> ();

        if (Input.GetMouseButtonDown(0))
        {
            this.gameObject.SetActive(false);
            charControlScript.enabled = true;
            timeScript.isGameStart    = true;
        }
    }
Esempio n. 15
0
    void OnChangeCharControl(CharControl character)
    {
        if (character == null)
        {
            return;
        }

        if (character.m_cameraTarget != null)
        {
            SetTarget(character.m_cameraTarget);
        }
        else
        {
            SetTarget(character.gameObject);
        }
    }
Esempio n. 16
0
    void Awake()
    {
        //object setup
        player           = GameObject.Find("Avatar");
        progressionFill  = transform.Find("ProgressBar").transform.Find("ProgressBarBacking").transform.Find("ProgressFill").GetComponent <Image>();
        upgradeName_Txt  = transform.Find("UpgradeName").GetComponent <Text>();
        CP_CostText      = transform.Find("AddLevel").transform.Find("CP Cost").transform.Find("CP Number").GetComponent <Text>();
        currentLevel_Txt = transform.Find("CurrentLevelBG").transform.Find("CurrentLevel").GetComponent <Text>();
        description_Txt  = transform.Find("Description").transform.Find("DescriptionText").GetComponent <Text>();
        currentCP_Txt    = GameObject.Find("PersonalStats").transform.Find("CurrentCP").GetComponent <Text>();
        resetButton      = transform.Find("ResetButton").GetComponent <Button>();
        max_Txt          = transform.Find("ProgressBar").transform.Find("MAX").GetComponent <Text>();

        charControlScript    = player.GetComponent <CharControl>();
        upgradeName_Txt.text = gameObject.name;
        currentNeededCP      = requiredCP;
    }
 // Use this for initialization
 void Start()
 {
     Cursor.visible   = false;
     Cursor.lockState = CursorLockMode.Locked;
     Player           = GameObject.FindGameObjectWithTag("Player");
     BossHealth       = Boss.GetComponent <EnemyHealth> ();
     //Boss = GameObject.FindGameObjectWithTag ("Boss");
     PlayerController = Player.GetComponent <CharControl> ();
     PlayerH          = Player.GetComponent <PlayerHealth> ();
     Pivote           = GameObject.Find("Pivote");
     pivotePos        = Pivote.GetComponent <PivotePos> ();
     EpicMusicSound   = EpicMusic.GetComponent <AudioSource> ();
     InitText.SetActive(true);
     Time.timeScale = 0;
     Reset.onClick.AddListener(Restart);
     //EpicMusic = GetComponent<AudioSource> ();
 }
Esempio n. 18
0
    private void Awake()
    {
        sfxControlScript  = GameObject.Find("SFXControl").GetComponent <SfxControl>();
        charControlScript = GetComponent <CharControl>();

        dayNightScript = GetComponent <DayNightCycle>();
        animController = transform.GetChild(1).GetComponent <Animator>();
        if (skipstart == false)
        {
            avatar.jumpVelocity = 0f;
        }
        campoints = camerapan.transform.position;

        /*if(DemoMode == false)
         * {
         *  camerapan = null;
         * }*/
    }
Esempio n. 19
0
    // Update is called once per frame
    void Update()
    {
        GameObject  charController    = GameObject.Find("Player");
        CharControl charControlScript = charController.GetComponent <CharControl> ();

        string timerTextInSeconds = string.Format("{1:00}", Mathf.Floor(totalTime / 60), totalTime % 60);

        if (isGameStart == false)
        {
            timerBG.enabled   = false;
            timerText.enabled = false;
            masterMixer.SetFloat("masterVol", 0f);
        }
        else if (isGameStart)
        {
            timerText.enabled = true;
            timerBG.enabled   = true;
            totalTime        -= Time.deltaTime;
            timerText.text    = timerTextInSeconds.ToString();
            masterMixer.SetFloat("masterVol", 10f);
        }

        if (totalTime <= 0f)
        {
            charControlScript.enabled = false;
            gameOver.enabled          = true;
            quitGame.enabled          = true;
            totalTime         = 0f;
            timerText.enabled = false;
            timerBG.enabled   = false;
            masterMixer.SetFloat("masterVol", -80f);
        }

        if (ObjectPickUp.haveIWon == true)
        {
            masterMixer.SetFloat("masterVol", -80f);

            if (hasSoundPlayed == false)
            {
                soundManager.PlayOneShot(hello, 1f);
                hasSoundPlayed = true;
            }
        }
    }
Esempio n. 20
0
    public void PoisonGet()
    {
        HP          = CharControl.PoisonDmg(HP, CharControl.Poison);
        poisonCount = poisonCount - 1;

        foreach (SpriteRenderer el in this.gameObject.GetComponentsInChildren <SpriteRenderer>())
        {
            el.color = new Color(0.9362738f, 1, 0.5707547f);
        }
        if (poisonCount == 0)
        {
            CancelInvoke("PoisonGet");
            foreach (SpriteRenderer el in this.gameObject.GetComponentsInChildren <SpriteRenderer>())
            {
                el.color = new Color(1, 1, 1);
            }
            poisonCount = 2;
        }
    }
Esempio n. 21
0
    public void TakeDamage(CharControl other, Vector3 hitPosition, Vector3 hitDirection, float amount)
    {
        //--------------------
        // direction example
        if (other != null)
        {
            transform.forward = -other.transform.forward;
        }
        else
        {
            hitDirection.y    = 0.0f;
            transform.forward = -hitDirection.normalized;
        }

        //--------------------
        // reaction animation example
        string reaction = m_damageReaction[0 /*Random.Range(0, m_damageReaction.Length)*/];             // random damage animation test

        m_ani.CrossFade(reaction, 0.1f, 0, 0.0f);
        //Health.fillAmount = 1 - (amount);

        /*
         * P1_H.value = 1 - var;
         * var += 0.2f;
         */

        P2_H.value = 1 - var;
        var       += 0.1f;
        if (P2_H.value < 0.25)
        {
            color.color = Color.red;
        }
        if (P2_H.value == 0)
        {
            m_ani.SetTrigger("Die");
            SceneManager.LoadScene(escena + 1);
        }

        //--------------------
        // hitFX example
        GameObject.Instantiate(m_hitEffect, hitPosition, Quaternion.identity);
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        maxHealth     = 300;
        currentHealth = 300;
        enemyName     = enemyNameList[Random.Range(0, enemyNameList.Length)];

        thisTransform = GetComponent <Transform>();
        thisRigidbody = GetComponent <Rigidbody>();

        player          = GameObject.Find("Player").GetComponent <CharControl>();
        playerTransform = player.GetComponent <Transform> ();

        GM = GameObject.Find("GameManager").GetComponent <GameManager>();


        switch (Random.Range(1, 5))
        {
        case 1:
            uiColor = Color.cyan;
            break;

        case 2:
            uiColor = Color.yellow;
            break;

        case 3:
            uiColor = Color.green;
            break;

        case 4:
            uiColor = Color.magenta;
            break;

        default:
            uiColor = Color.magenta;
            break;
        }

        defaultMovement = Random.Range(9, 12);
        turnSpeed       = Random.Range(7, 11);
    }
Esempio n. 23
0
    private void Awake()
    {
        #region Giving variable values
        floattimer = 10f;
        //TabManaging = GameObject.Find("TabManager").GetComponent<tabchanger>();
        storycheck = GameObject.Find("Avatar").GetComponent <StoryChecker>();
        Controller = transform.GetComponent <CharControl>();
        woosh      = GetComponent <AudioSource>();
        rb         = GetComponent <Rigidbody>();
        if (storycheck.DemoMode)
        {
            inventory = GameObject.FindGameObjectWithTag("itemui");
        }
        #endregion
        #region setting variable status
        respawnertext.enabled = false;
        inventory.SetActive(false);

        Cursor.visible = false;
        #endregion
    }
Esempio n. 24
0
    public static void ShowSelected(int number)
    {
        Int_Intern_Options.SetActive(false);
        Int_Intern_Desc.SetActive(true);

        TextMeshProUGUI desc = Int_Intern_Desc.GetComponent <TextMeshProUGUI>();

        if (number == 0 && desc != null)
        {
            desc.text = CharControl.GetLastCard().Meaning1;
        }
        if (number == 1 && desc != null)
        {
            desc.text = CharControl.GetLastCard().Meaning2;
        }
        if (number == 2 && desc != null)
        {
            desc.text = CharControl.GetLastCard().Meaning3;
        }

        GameState = 2;
    }
Esempio n. 25
0
    public void SpwanCharacter(GameObject prefab)
    {
        DeleteCharacter();

        GameObject obj = GameObject.Instantiate(prefab, transform.position, transform.rotation) as GameObject;

        m_character = obj;

        CharControl cc = obj.GetComponent <CharControl>();

        if (cc != null)
        {
            if (m_mainCharacter == true)
            {
                cc.Select();
            }
            else
            {
                cc.m_enableControl = false;
            }
        }
    }
 public void Start()
 {
     sfxScript         = GameObject.Find("SFXControl").GetComponent <SfxControl>();
     charControlScript = GameObject.Find("Avatar").GetComponent <CharControl>();
     notice.SetActive(false);
 }
Esempio n. 27
0
 public void setTarget(CharControl newTarget)
 {
     target = newTarget;
 }
Esempio n. 28
0
 // Use this for initialization
 void Start()
 {
     charControlScript       = player.GetComponent <CharControl>();
     currentVelocityModifier = cloudParticles.velocityOverLifetime.speedModifierMultiplier;
 }
    void OnChangeCharControl(CharControl character)
    {
        m_currentCharControl = character;

        m_characterHelp = m_currentCharControl.GetHelpText();
    }
Esempio n. 30
0
 public void Start()
 {
     text      = GetComponent <Text>();
     thePlayer = GameObject.Find("BoyCharacter");
     control   = thePlayer.GetComponent <CharControl>();
 }