예제 #1
0
 void OnMouseDown()
 {
     if (gameObject.name == "Start")
     {
         camera.GetComponent <Camera_script>().AppearB();
         play = true;
     }
     if (gameObject.name == "Return")
     {
         Camera_script cs = camera.GetComponent <Camera_script>();
         cs.target = new Vector3(0, 0, -10);
         StartCoroutine(cs.Transition());
     }
     if (gameObject.name == "Credits")
     {
         Camera_script cs = camera.GetComponent <Camera_script>();
         cs.target = new Vector3(-28, 0, -10);
         StartCoroutine(cs.Transition());
     }
     if (gameObject.name == "HowToPlay")
     {
         Camera_script cs = camera.GetComponent <Camera_script>();
         cs.target = new Vector3(24.5f, 0, -10);
         StartCoroutine(cs.Transition());
     }
     if (gameObject.name == "Exit")
     {
         Application.Quit();
     }
 }
예제 #2
0
    public void PlayerDied()
    {
        GameObject    camera = GameObject.Find("MainCamera");
        Camera_script cs     = camera.GetComponent <Camera_script>();

        cs.DisappearB();
        StartCoroutine(LoadMenu());
    }
예제 #3
0
 void Awake()
 {
     rb         = gameObject.GetComponent <Rigidbody2D>();
     cam        = Camera.main.gameObject.GetComponent <Camera_script>();
     cam.player = this.gameObject;
     cam.offset = transform.position - Camera.main.transform.position;
     Inventory  = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Canvas>();
     manager    = GameObject.FindGameObjectWithTag("Manager").GetComponent <Manager>();
     anim       = GetComponent <Animator>();
 }
예제 #4
0
 void Awake()
 {
     if (Instance) // PRevents creation of camera clones when loading new level
     {
         Destroy(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
     }
 }
예제 #5
0
 void Awake()
 {
     rigidBody      = GetComponent <Rigidbody2D>();
     MainCamera     = GameObject.Find("Game_Camera").GetComponent <Camera_script>();
     muzzle_R       = GameObject.Find("Muzzle_R");
     muzzle_L       = GameObject.Find("Muzzle_L");
     Dima_Animator  = GetComponent <Animator>();
     RightArmSolver = GameObject.Find("RightArmSolver");
     LeftArmSolver  = GameObject.Find("LeftArmSolver");
     Arm_R_Effector = GameObject.Find("Arm_R_Effector");
     Arm_L_Effector = GameObject.Find("Arm_L_Effector");
     overlord       = GameObject.Find("OVERLORD").GetComponent <Overlord_script>();
 }
예제 #6
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player" && isOpen == true)
     {
         collision.transform.position = new Vector2(findPosition.X, findPosition.Y);
         TestMovement t = collision.gameObject.GetComponent <TestMovement>();
         parent = exitPoint.transform.parent.gameObject;
         collision.transform.parent = parent.transform;
         parent.transform.TransformPoint(Vector3.zero);
         GameObject    middle = parent.transform.Find("Mid").gameObject;
         GameObject    camera = GameObject.Find("Main Camera");
         Camera_script s      = camera.GetComponent <Camera_script>();
         s.target = new Vector3(middle.transform.position.x, middle.transform.position.y, -10);
         StartCoroutine(camera.GetComponent <Camera_script>().Transition());
         t.passing();
     }
 }
예제 #7
0
 void FixedUpdate()
 {
     if (Input.GetKeyDown(KeyCode.E) && active && player.transform.parent.name == roomName && E.activeSelf && timer < 0)
     {
         TestMovement t = player.gameObject.GetComponent <TestMovement>();
         player.transform.position = new Vector2(findPosition.X, findPosition.Y);
         parent = exitPoint.transform.parent.gameObject;
         player.transform.parent = parent.transform;
         parent.transform.TransformPoint(Vector3.zero);
         GameObject    middle = parent.transform.Find("Mid").gameObject;
         GameObject    camera = GameObject.Find("Main Camera");
         Camera_script s      = camera.GetComponent <Camera_script>();
         //s.target = parent.transform;
         s.target = new Vector3(middle.transform.position.x, middle.transform.position.y, -10);
         //camera.target = parent;
         StartCoroutine(camera.GetComponent <Camera_script>().Transition());
         t.passing();
     }
 }
예제 #8
0
 // Start is called before the first frame update
 void Start()
 {
     //Get the ui script
     ui = GetComponent <ui_script>();
     //get the camera script
     camera           = GetComponent <Camera_script>();
     controlled_units = new List <unit_control_script>();
     canvas           = GetComponent <Canvas>();
     //add all of the manually added units to the controlled units group
     foreach (GameObject unit in ManuallyAddedUnits)
     {
         controlled_units.Add(unit.GetComponent <unit_control_script>());
         main_unit = unit.GetComponent <unit_control_script>();
         //set the unit control script unit
     }
     ui.SetActiveUnit(main_unit);
     camera.SetActiveUnit(main_unit);
     //register player with the game manager
     game_manager.GetGameManager().RegisterPlayer(gameObject);
 }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        newPos = gameObject.transform.position;
        if (CharacterStats.hp < 0)
        {
            Camera_script cs = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera_script>();
            Vector3       v3 = transform.position;
            v3.y += 0.5f;
            GameObject p = Instantiate(Resources.Load("Prefabs/Poof", typeof(GameObject)) as GameObject, v3, Quaternion.identity);
            Destroy(p, 0.85f);
            cs.PlayerDied();
            Destroy(gameObject);
            Destroy(this);
        }
        //anim.SetFloat("Speed", (oldPos-newPos).magnitude);
        if (running == 0 && r == true)
        {
            r = false;
            anim.SetInteger("Running", 0);
        }
        else if (running == 1 && r == true)
        {
            anim.SetInteger("Running", 1);
        }
        else
        {
            anim.SetInteger("Running", -1);
        }


        speed = oldPos.x - newPos.x;
        ChangeDirection(speed);
        active          -= Time.deltaTime;
        timer           -= Time.deltaTime;
        moved           -= Time.deltaTime;
        invulnerability -= Time.deltaTime;
        player.velocity  = new Vector3(0, 0, 0);
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePos.z = 0;
        var relativePos = mousePos - transform.position;

        if (right)
        {
            angle = (Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg) + 200;
        }
        else
        {
            angle = (Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg) + 20;
        }

        var rotation = Quaternion.AngleAxis(angle, Vector3.forward);

        scythe.transform.rotation = rotation;
        oldPos = newPos;
        if (Input.GetMouseButtonDown(0) && timer < 0)
        {
            animator.SetTrigger("HasAtacked");
            switch (CharacterStats.weaponType)
            {
            case 1:
                timer = CharacterStats.atackSpeed;
                break;

            case 2:
                timer = CharacterStats.atackSpeed + CharacterStats.atackSpeed / 2;
                break;

            case 3:
                timer = CharacterStats.atackSpeed / 4;
                break;

            case 4:
                timer = CharacterStats.atackSpeed * 3;
                break;
            }
            startPos.x = transform.position.x;
            startPos.y = transform.position.y;
            double distance = Math.Sqrt(Math.Pow((mousePos.x - startPos.x), 2) + Math.Pow((mousePos.y - startPos.y), 2));
            double T        = CharacterStats.range / distance;
            atackPos.x = (float)((1 - T) * startPos.x + T * mousePos.x);
            atackPos.y = (float)((1 - T) * startPos.y + T * mousePos.y);
            angle      = (Mathf.Atan2(relativePos.y, relativePos.x) * Mathf.Rad2Deg);
            rotation   = Quaternion.AngleAxis(angle, Vector3.forward);
            GameObject slash = Instantiate(atack, new Vector3(atackPos.x, atackPos.y, 0), rotation);
            audioData.Play();
        }

        //Quaternion target = Quaternion.Euler(0, 0, angle);
        //scythe.transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * 5);
    }