void Start()
 {
     rb                     = GetComponent <Rigidbody>();
     control                = GetComponent <SimpleCharacterControl>();
     gameOverText           = gameOverCanvas.gameObject.GetComponentInChildren <Text>();
     gameOverCanvas.enabled = false;
 }
Exemple #2
0
 public void Init()
 {
     dna         = new DNA(DNALength, 6);
     m_Character = GetComponent <SimpleCharacterControl>();
     timeAlive   = 0;
     alive       = true;
 }
Exemple #3
0
    void CanWalk()
    {
        GameObject             player       = GameObject.Find("Player");
        SimpleCharacterControl playerScript = player.GetComponent <SimpleCharacterControl>();

        playerScript.canWalk = true;
        player_anim.enabled  = true;
    }
Exemple #4
0
 // Use this for initialization
 void Start()
 {
     characterController = GetComponentInParent <SimpleCharacterControl>();
     if (_current_item)
     {
         GameObject spawn_object = this.gameObject.transform.Find("SpawnPoint").gameObject;
         Instantiate(_current_item, spawn_object.transform.position, Quaternion.identity, this.gameObject.transform);
     }
 }
Exemple #5
0
 // Start is called before the first frame update
 void Start()
 {
     hasShield  = false;
     shieldIsUp = false;
     hasSpeedUp = false;
     hasPowerUp = false;
     cc         = GetComponent <SimpleCharacterControl>();
     pc         = GetComponent <PlayerController>();
 }
    bool damaged;                                                   // True when the player gets damaged.


    void Awake()
    {
        // Setting up the references.
        anim           = GetComponent <Animator> ();
        playerAudio    = GetComponent <AudioSource> ();
        playerMovement = GetComponent <SimpleCharacterControl> ();
        //playerShooting = GetComponentInChildren <PlayerShooting> ();

        // Set the initial health of the player.
        currentHealth = startingHealth;
    }
Exemple #7
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "pickup")
        {
            //collision.gameObject.GetComponent<BoxCollider>().enabled = false;
            string itemName = collision.gameObject.GetComponent <Pickup>().name;
            if (Array.IndexOf(itemsToBeCollected, itemName) > -1)
            {
                audioS.clip = collision.gameObject.GetComponent <Pickup>().soundWhenAcquired;
                audioS.Play();
                transform.parent.GetComponentInChildren <PlayerActions>().addPoint();
                SimpleCharacterControl charTemp    = transform.parent.GetComponentInChildren <SimpleCharacterControl>();
                PlayerActions          actionsTemp = transform.parent.GetComponentInChildren <PlayerActions>();

                GameObject.Find("Panel" + GameStatics.numberOfPlayers + "Players").transform.Find("PanelPlayer" + charTemp.playerID).Find(itemName).GetComponent <Image>().sprite = img;
                Destroy(collision.gameObject);
            }
        }
    }
Exemple #8
0
    void Clone4()
    {
        cloned4 = true;
        GameObject player_clone3 = GameObject.Find("Player_Clone_3");

        clone4_pos = GameObject.Find("Player_Clone_3").transform.position;
        Vector3 clone3_direction = player_clone3.transform.forward;

        clone4_spwn = clone4_pos + clone3_direction;
        Quaternion             clone4_rot   = player_clone3.GetComponent <Transform>().rotation;
        SimpleCharacterControl playerScript = player_clone3.GetComponent <SimpleCharacterControl>();
        Object clone_obj = Instantiate(player_clone3, clone4_spwn, clone4_rot);

        clone_obj.name       = "Player_Clone_4";
        playerScript.canWalk = false;
        player_anim.enabled  = false; //andrà sostituito con l' animazione di dejavu
        if (istalking == false)
        {
            Invoke("Destroy4", 6.5f);
        }
    }
Exemple #9
0
    void Clone()
    {
        cloned = true;
        GameObject             player       = GameObject.Find("Player");
        SimpleCharacterControl playerScript = player.GetComponent <SimpleCharacterControl>();

        player.tag = "Player_Clone";
        Vector3 player_direction = player.transform.forward;

        clone_spwn = clone_pos + player_direction;
        Quaternion clone_rot = player.transform.rotation;
        Object     clone_obj = Instantiate(player_obj, clone_spwn, clone_rot);

        clone_obj.name       = "Player_Clone";
        playerScript.canWalk = false;
        player_anim.enabled  = false; //andrà sostituito con l' animazione di dejavu
        player.tag           = "Player";
        if (istalking == false)
        {
            Invoke("Destroy", 6f);
        }
    }
    void CloseDialogue()
    {
        if (clonedwithq == false && clonedtalking == false)
        {
            dialoguecompleted = true;
        }
        Debug.Log(dialoguecompleted);
        epressed = false;
        textimage.gameObject.SetActive(false);
        y = 0;
        Debug.Log(y);
        textimage.interactable = false;
        clonedwithq            = false;
        qpressed1 = false;
        GameObject      cloneController       = GameObject.Find("Clone_Controller");
        CloneController cloneControllerScript = cloneController.GetComponent <CloneController>();

        cloneControllerScript.istalking       = false;
        cloneControllerScript.finishedtalking = true;
        clone_near = false;
        if (clonedtalking == true)
        {
            clonedtalking = false;
            GameObject clone = GameObject.FindGameObjectWithTag("Player_Clone");
            if (cloneControllerScript.cloned == true)
            {
                SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                cloneScript.canWalk = true;
            }
        }
        else
        {
            GameObject             player       = GameObject.Find("Player");
            SimpleCharacterControl playerScript = player.GetComponent <SimpleCharacterControl>();
            playerScript.canWalk = true;
        }

        //checka se è un clone o il player e canWalk torna true, fare tutto su close dialogue, if y > x invoke CloseDialogue
    }
Exemple #11
0
        public void Start()
        {
            Seed = System.Guid.NewGuid().ToString().Substring(0, 8).ToUpper();
            Random.InitState(Seed.GetHashCode());

            lt           = GameObject.Find("Directional Light");
            textures1[0] = Resources.Load("dirt stones") as Texture;
            textures2[0] = Resources.Load("leafs dark") as Texture;
            textures1[1] = Resources.Load("dirt stones eary yellow") as Texture;
            textures2[1] = Resources.Load("dirt stones leafs more") as Texture;
            textures1[2] = Resources.Load("grey dirt stones") as Texture;
            textures2[2] = Resources.Load("granit grass") as Texture;
            textures1[3] = Resources.Load("dirt stones") as Texture;
            textures2[3] = Resources.Load("sand stones") as Texture;

            LoadSkyBoxMaterials();

            int rnd = (int)(Random.Range(0f, 0.3f) * 10);

            Ground.texture1 = textures1[rnd];
            Ground.texture2 = textures2[rnd];

            #region LevelProcessor

            GameObject levelProcessor = new GameObject();
            lpObj = levelProcessor.AddComponent <LevelProcessor>();
            lpObj.ProcessLevel(bunnyPrefab, ghostPrefab);

            #endregion

            transform.position = lpObj.startingPosition;

            #region Character

            characterTransform = Instantiate(characterPrefab, transform.position, transform.rotation);
            SimpleCharacterControl sCC = characterTransform.GetComponent <SimpleCharacterControl>();
            sCC.m_jumpForce             = lpObj.maxJumpHeight * 3; // TODO: Find right multiply and maybe addition
            sCC.m_moveSpeed             = 5;
            characterTransform.position = lpObj.startingPosition;
            characterTransform.rotation = Quaternion.AngleAxis(90, new Vector3(0, 1, 0));
            Debug.Log("starting position = " + lpObj.startingPosition);

            Camera camera = this.GetComponent <Camera>();

            camera.transform.parent = characterTransform.transform;
            Vector3 localPosition = camera.transform.localPosition;
            localPosition.x = 10;
            camera.transform.localPosition = localPosition;

            #endregion

            #region Skybox and Music

            Material m = Resources.Load("CloudyCrownMidday", typeof(Material)) as Material;
            Debug.Log("Matieral-Name: " + m.name);
            RenderSettings.skybox = m;

            audio     = gameObject.AddComponent <AudioSource>();
            acMorning = Resources.Load("Songs/Morning") as AudioClip;
            acSundown = Resources.Load("Songs/Sundown") as AudioClip;
            acDoD     = Resources.Load("Songs/Dance Of Death") as AudioClip;
            acOutcast = Resources.Load("Songs/Outcast") as AudioClip;

            audio.clip   = acMorning;
            audio.loop   = true;
            audio.volume = 0.1f;
            audio.Play();
            #endregion
        }
Exemple #12
0
    public IEnumerator Create()
    {
        countToDestroy = 0;
        int       x     = 0;
        int       z     = 0;
        TextAsset asset = Resources.Load("level" + level) as TextAsset;

        sv = JsonUtility.FromJson <Level> (asset.text);
        string[] lines = sv.wave.Split(new char[] { '/' });

        x              = (lines [0].Length + 1) / 2;
        generalCount   = lines.Length * x;
        countToDestroy = generalCount;

        SimpleCharacterControl player = FindObjectOfType <SimpleCharacterControl>();

        player.Clean();
        //CameraScript cam = player.GetComponentInChildren<CameraScript>();
        CameraScript cam = Camera.main.GetComponent <CameraScript>();


        PlatformLength platform = GetComponent <PlatformLength> ();

        if (platform != null)
        {
            if (x != platform.PlatformWidth(x))
            {
                cam.Posit(x);
            }
        }

        x = 0;

        yield return(new WaitUntil(() => timer > (-lines.Length - 1f)));

        foreach (String line in lines)
        {
            x = 0;
            Debug.Log(line);
            string[] blocks = line.Split(new char[] { ' ' });
            foreach (String block in blocks)
            {
                switch (block)
                {
                case "1":
                    Instantiate(basicCube, new Vector3(x, 0.47f, z), Quaternion.identity);
                    countToDestroy++;
                    break;

                case "2":
                    Instantiate(greenCube, new Vector3(x, 0.47f, z), Quaternion.identity);
                    countToDestroy++;
                    break;

                case "3":
                    Instantiate(blackCube, new Vector3(x, 0.47f, z), Quaternion.identity);
                    break;
                }
                x++;
            }
            yield return(new WaitForSeconds(0.5f));

            z++;
        }
        countToDestroy -= generalCount;
    }
Exemple #13
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     LogHelper.Log(typeof(WalkBackBehavior), "Entered Idle");
     this._controller = animator.GetComponentInParent <SimpleCharacterControl>();
     this._controller.MoveByInput(0, 0, false);
 }
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     this._controller = animator.GetComponentInParent <SimpleCharacterControl>();
     this.aiParams    = animator.GetComponentInParent <AIParameterSetter>();
     LogHelper.Log(typeof(ChaseBehavior), "Entered Chase");
 }
 void CheckIfEPressed()
 {
     if (epressed == false)
     {
         if (player_near == true || clone_near == true)
         {
             if (Input.GetKeyDown(KeyCode.E))
             {
                 epressed = true;
                 GameObject      cloneController       = GameObject.Find("Clone_Controller");
                 CloneController cloneControllerScript = cloneController.GetComponent <CloneController>();
                 bool            checkclone            = cloneControllerScript.cloned;
                 if (player_near == true && clone_near == false && checkclone == false)
                 {
                     GameObject             player       = GameObject.Find("Player");
                     SimpleCharacterControl playerScript = player.GetComponent <SimpleCharacterControl>();
                     playerScript.canWalk            = false;
                     cloneControllerScript.istalking = true;
                     StartDialoguePlayer();
                 }
                 else if (player_near == false && clone_near == true)
                 {
                     if (cloneControllerScript.cloned == true && cloneControllerScript.cloned1 == false)
                     {
                         GameObject             clone       = GameObject.Find("Player_Clone");
                         SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                         cloneScript.canWalk             = false;
                         cloneControllerScript.istalking = true;
                     }
                     else if (cloneControllerScript.cloned == true && cloneControllerScript.cloned1 == true && cloneControllerScript.cloned2 == false)
                     {
                         GameObject             clone       = GameObject.Find("Player_Clone_1");
                         SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                         cloneScript.canWalk             = false;
                         cloneControllerScript.istalking = true;
                     }
                     else if (cloneControllerScript.cloned == true && cloneControllerScript.cloned1 == true && cloneControllerScript.cloned2 == true && cloneControllerScript.cloned3 == false)
                     {
                         GameObject             clone       = GameObject.Find("Player_Clone_2");
                         SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                         cloneScript.canWalk             = false;
                         cloneControllerScript.istalking = true;
                     }
                     else if (cloneControllerScript.cloned == true && cloneControllerScript.cloned1 == true && cloneControllerScript.cloned2 == true && cloneControllerScript.cloned3 == true && cloneControllerScript.cloned4 == false)
                     {
                         GameObject             clone       = GameObject.Find("Player_Clone_3");
                         SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                         cloneScript.canWalk             = false;
                         cloneControllerScript.istalking = true;
                     }
                     else
                     {
                         GameObject             clone       = GameObject.Find("Player_Clone_4");
                         SimpleCharacterControl cloneScript = clone.GetComponent <SimpleCharacterControl>();
                         cloneScript.canWalk             = false;
                         cloneControllerScript.istalking = true;
                     }
                     StartDialogueClone();
                 }
                 else if (player_near == true && clone_near == true)
                 {
                     Debug.Log("You can't both start a dialogue with the same npc");
                 }
                 Talk();
             }
         }
     }
 }