コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //バックグラウンド作成
        GameObject go;

        go = Instantiate((GameObject)Resources.Load("Prefabs/TitleBackGround"));
        go.transform.parent = this.transform;

        //木漏れ日1
        go = Instantiate((GameObject)Resources.Load("Prefabs/TreeLight"));
        go.transform.parent = this.transform;

        //木漏れ日2
        go = Instantiate((GameObject)Resources.Load("Prefabs/TreeLight"));
        go.transform.parent = this.transform;
        Vector3 pos = go.transform.position;

//        pos.x = -2.0f;
        go.transform.position = pos;
        go.GetComponent <TreeLightController>().progress = 0.0005f;

        //マスキング用スプライト
        go = Instantiate((GameObject)Resources.Load("Prefabs/MaskSprite"));
        go.transform.parent = this.transform;
        go.GetComponent <MaskSpriteController>().RotateOut(1.0f);

        this.soundManager = SoundManagerController.Instance;
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        float xMov = Input.GetAxisRaw("Horizontal");
        float yMov = Input.GetAxisRaw("Vertical");
        float zMov = Input.GetAxisRaw("Jump");

        Vector3 movHorizontal = transform.right * xMov;
        Vector3 movVertical   = transform.forward * yMov;
        Vector3 movUp         = transform.up * zMov;

        velocity = (movHorizontal + movVertical + movUp).normalized * speed;

        transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * Time.deltaTime * mouseSensitivity);
        verticalLookRotation += Input.GetAxis("Mouse Y") * Time.deltaTime * mouseSensitivity;
        verticalLookRotation  = Mathf.Clamp(verticalLookRotation, -60, 60);
        cam.localEulerAngles  = Vector3.left * verticalLookRotation;
        enemyText.text        = "Monstruos Eliminados: " + enemyCount.ToString();

        if (count >= 13 && enemyCount >= 5 && !gano)
        {
            gano         = true;
            winText.text = "Felicidades Completaste el Nivel!! \nAlumno: Carlos Blanco \ndSimulación por Computadora \n";
            SoundManagerController.PlaySound("win");
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
        }
    }
コード例 #3
0
 public void Activate()
 {
     SoundManagerController.PlaySound("Shield");
     poligonCollider.enabled = true;
     activated = true;
     animator.SetBool("Casting", true);
 }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        moveHorizontal = Input.GetAxis("Horizontal_P2");
        moveVertical   = Input.GetAxis("Vertical_P2");

        if (!myAttack)
        {
            Move();
            Attack();
            Defensive();
        }

        /*Vector2 position = new Vector2(Mathf.Clamp(transform.position.x, xMin, xMax),
         *  Mathf.Clamp(transform.position.y, yMin, yMax));
         * transform.position = position;*/
        if (hitPoints <= 0)
        {
            Dead();
        }

        if (damageTaken > 0)
        {
            hitPoints  -= damageTaken;
            damageTaken = 0;
            StartCoroutine("HurtColor");
            Instantiate(deathPrefab, transform.position, transform.rotation);
            SoundManagerController.PlaySound("Hit");
        }



        SpecialAttack();
    }
コード例 #5
0
	// Use this for initialization
	void Awake () {
		if (instance == null)
			instance = this;
		else if (instance != this)
			Destroy (gameObject);
		
		DontDestroyOnLoad (gameObject);
	}
コード例 #6
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Enemy"))
     {
         SoundManagerController.PlaySound("hit");
         other.gameObject.SetActive(false);
         FPController.IncrementaEnemyCount();
     }
 }
コード例 #7
0
 private void JumpListenner()
 {
     if (Input.GetKeyDown(jumpKey) && remainingJumps > 0)
     {
         InstantiateCloud();
         SoundManagerController.PlaySound("Jump");
         rb.velocity = Vector2.up * jumpForce;
         remainingJumps--;
     }
 }
コード例 #8
0
    // Use this for initialization
    void Start()
    {
        //スプラッシュ用ビュー
        GameObject view = Instantiate((GameObject)Resources.Load("Prefabs/SplashView"));

        view.transform.parent = this.transform;

        this.soundManager = SoundManagerController.Instance;
        this.soundManager.addSound("splash", "Sounds/se_maoudamashii_onepoint05");

        StartCoroutine(playSoundCoroutine(1.8f));
    }
コード例 #9
0
ファイル: BallController.cs プロジェクト: hiagolcm/MageDodge
    private void OnCollisionEnter2D(Collision2D collision)
    {
        SoundManagerController.PlaySound("Bounce");
        if (collision.gameObject.name == "Shield" || collision.gameObject.name == "RedShield")
        {
            cameraController.CamShake();

            Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
            direction.Normalize();
            rb.AddForce(direction * bounceForce);
        }
    }
コード例 #10
0
 private void Awake()
 {
     //If multiple Instances of this class is created then Don't destroy this one and destroy others
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
コード例 #11
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
コード例 #12
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Pick Up"))
     {
         SoundManagerController.PlaySound("ping");
         other.gameObject.SetActive(false);
         count++;
         SetCountText();
     }
     if (other.gameObject.CompareTag("Pieces"))
     {
         other.gameObject.SetActive(false);
     }
 }
コード例 #13
0
    // Use this for initialization
    void Start()
    {
        //タイトル用キャンバス
        GameObject cvs = Instantiate((GameObject)Resources.Load("Prefabs/TitleCanvas"));

        cvs.transform.parent = this.transform;

        //タイトル用ビュー
        GameObject view = Instantiate((GameObject)Resources.Load("Prefabs/TitleView"));

        view.transform.parent = this.transform;

        this.soundManager = SoundManagerController.Instance;
        this.soundManager.addSound("start", "Sounds/soundlogo41");
    }
コード例 #14
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
     }
     DontDestroyOnLoad(gameObject);
     musicAudioSource  = gameObject.AddComponent <AudioSource>();
     musicAudioSource2 = gameObject.AddComponent <AudioSource>();
     sfxAudioSource    = gameObject.AddComponent <AudioSource>();
 }
コード例 #15
0
    private void OnCollisionEnter(Collision collision)
    {
        switch (collision.gameObject.tag)
        {
        case TagConstants.Coin:
        {
            SoundManagerController.Play(SoundConstants.CoinCollect);
            Destroy(collision.gameObject);
            AddScore(1);
            break;
        }

        case TagConstants.Mine:
        {
            SoundManagerController.Play(SoundConstants.MineExplosion);
            Destroy(collision.gameObject);
            AddHp(-Settings.gameSettings.damage.mine);
            break;
        }

        case TagConstants.Turkey:
        {
            SoundManagerController.Play(SoundConstants.EatTurkey);
            Destroy(collision.gameObject);
            AddHp(Settings.gameSettings.heal.turkey);
            break;
        }

        default:
        {
            break;
        }
        }

        ContactPoint[] contactPoints = collision.contacts;
        for (int i = 0; i < contactPoints.Length; i++)
        {
            if (Vector3.Dot(contactPoints[i].normal, Vector3.up) > 0.5f)
            {
                if (!_collisions.Contains(collision.collider))
                {
                    _collisions.Add(collision.collider);
                }
                _isGrounded = true;
            }
        }
    }
コード例 #16
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            SoundManagerController.PlaySound("shoot");
            GameObject Temporary_Bullet_Handler;
            Temporary_Bullet_Handler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;

            Temporary_Bullet_Handler.transform.Rotate(Vector3.left * 90);

            Rigidbody Temporary_RigidBody;
            Temporary_RigidBody = Temporary_Bullet_Handler.GetComponent <Rigidbody>();

            Temporary_RigidBody.AddForce(transform.forward * Bullet_Forward_Force);

            Destroy(Temporary_Bullet_Handler, 10.0f);
        }
    }
コード例 #17
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.name == "Ball" && !dead)
        {
            timeController.SlowTrigger();
            //rb.velocity = new Vector2(0, 0);
            SoundManagerController.PlaySound("Dead");
            animator.SetTrigger("Dead");
            dead = true;
            scoreManager.TriggerWin(enemyPlayerIndex);
        }

        if (collision.gameObject.name == "Tilemap" && !isOnTheWall())
        {
            InstantiateCloud();
            SoundManagerController.PlaySound("HitTheGround");
        }
    }
コード例 #18
0
    // Use this for initialization
    void Start()
    {
        int numStage = 1;

        //チュートリアル準備
        for (int i = 0; i < this.maxPage; i++)
        {
            string     name      = "Prefabs/Tutorial" + numStage;
            GameObject tutorial1 = Instantiate((GameObject)Resources.Load(name + "_" + (i + 1)));
            tutorial1.transform.SetParent(this.transform);
            tutorial1.transform.position = new Vector3(6.0f * i, 0.0f);
            this.tutorial.Add(tutorial1);
        }
        this.tutorial[0].transform.position = new Vector3(0, 10.0f);
        this.tutorial[0].GetComponent <TutorialPanelController>().screenIn();

        //サウンドマネージャー取得
        this.soundManager = SoundManagerController.Instance;
    }
コード例 #19
0
    // Use this for initialization
    void Start()
    {
        //アプリケーションマネージャー取得
        this.app = ApplicationManagerController.Instance;
        this.app.currentSceneManager = this.gameObject;

        //ステージ情報
        this.app.playingStageNumber = this.startStageNumber;

        //サウンドマネージャー取得
        this.soundManager = SoundManagerController.Instance;
        //使用音声ファイル読み込み
        this.soundManager.addSound("bgm_clear", "Sounds/bgm_StageClear");
        this.soundManager.addSound("bgm_allclear", "Sounds/bgm_StageAllClear");
        this.soundManager.addSound("playermiss", "Sounds/se_PlayerMiss");
        this.soundManager.addSound("paneldrop", "Sounds/se_PanelThrough");
        this.soundManager.addSound("getitem", "Sounds/se_GetItem");
        this.soundManager.addSound("gameover", "Sounds/gameover");

        this.setupScene();
    }
コード例 #20
0
    // Use this for initialization
    void Start()
    {
        this.actorBase = GameObject.Find("ActorBase");
        this.iconBase  = GameObject.Find("IconBase");

        //アクター配置
        this.addActor();
        this.addActor();
        this.addActor();
        this.addActor();
        this.addActor();

        this.actors[0].transform.position = new Vector3(0, 0, 0);
        this.initIconPosition(0);

        //フェード初期処理
        this.fadeStar = this.fadeStarCanvas.GetComponent <Fade>();

        //タップエフェクト
        GameObject go = Instantiate((GameObject)Resources.Load("Prefabs/TapEffect"));

        go.transform.parent = this.transform;
        this.tapEffect      = go.GetComponent <TapEffect>();

        //シーン開始フェード
        GameObject fd = Instantiate((GameObject)Resources.Load("Prefabs/Mask_first"));

        //アプリケーションマネージャー取得
        this.app          = ApplicationManagerController.Instance;
        app.selectedActor = 0;

        //サウンドマネージャー取得
        this.soundManager = SoundManagerController.Instance;
        this.soundManager.addSound("bgm_select", "Sounds/DS-091m");
        this.soundManager.addSound("change", "Sounds/yf_cursor22");
        this.soundManager.addSound("openselect", "Sounds/se_maoudamashii_se_paper01");
        this.soundManager.addSound("cancel", "Sounds/se_maoudamashii_system36");
        soundManager.playBGM("bgm_select");
    }
コード例 #21
0
    // Use this for initialization
    void Start()
    {
        //チュートリアル画面用ビュー
        GameObject view = Instantiate((GameObject)Resources.Load("Prefabs/TutorialSceneView"));

        view.transform.SetParent(this.transform);
        this.sceneView           = view;
        this.sceneViewController = view.GetComponent <GameSceneViewController>();

        //ゲーム画面用キャンバス
        GameObject canvas = Instantiate((GameObject)Resources.Load("Prefabs/TutorialSceneCanvas"));

        canvas.transform.SetParent(this.transform);
        this.sceneCanvas           = canvas;
        this.SceneCanvasController = canvas.GetComponent <GameSceneCanvasController>();

        //サウンドマネージャー取得
        this.soundManager = SoundManagerController.Instance;
        this.soundManager.addSound("bgm_tutorial", "Sounds/bgm_tutorial");
        this.soundManager.addSound("change", "Sounds/yf_cursor22");

        soundManager.playBGM("bgm_tutorial", 3.0f);
    }
コード例 #22
0
    private void Attack()
    {
        // My attack
        if (Input.GetButton("Fire1_P2") && !myAttack)
        {
            if (facingRight)
            {
                float x2 = transform.position.x + 0.5f;
                float y2 = transform.position.y;
                myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                myAttack.GetComponent <AttackController>().myEnemy = "Minion";
                SoundManagerController.PlaySound("Swish");
            }
            if (!facingRight)
            {
                float x2 = transform.position.x - 0.5f;
                float y2 = transform.position.y;
                myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                myAttack.GetComponent <AttackController>().myEnemy = "Minion";
                myAttack.GetComponent <SpriteRenderer>().flipX     = true;
                SoundManagerController.PlaySound("Swish");
            }
        }

        #region Janne Attack

        /*
         * if (Input.GetButton("Fire1") && Time.time > nextFire)
         * {
         *  nextFire = Time.time + attackSpeed;
         *  if (moveHorizontal < 0 && moveVertical > 0)
         *  {
         *      anim.SetTrigger("AttackUpSide");
         *      //Debug.Log("Player Attacks Up Side left");
         *  }
         *  if (moveHorizontal == -1 || moveHorizontal == 1 && moveVertical == 0)
         *  {
         *      anim.SetTrigger("Attack");
         *      //Debug.Log("Player Attacks left");
         *  }
         *  if (moveHorizontal < 0 && moveVertical < 0)
         *  {
         *      anim.SetTrigger("AttackDownSide");
         *      //Debug.Log("Player Down Side left");
         *  }
         *  if (moveHorizontal == 0 && moveVertical == -1)
         *  {
         *      anim.SetTrigger("AttackDown");
         *      //Debug.Log("Player Attacks Down");
         *  }
         *  if (moveHorizontal > 0 && moveVertical < 0)
         *  {
         *      anim.SetTrigger("AttackDownSide");
         *      //Debug.Log("Player Down Side right");
         *  }
         *
         *  if (moveHorizontal == 1 && moveVertical == 0)
         *  {
         *      anim.SetTrigger("Attack");
         *      //Debug.Log("Player Attacks right");
         *  }
         *
         *  if (moveHorizontal > 0 && moveVertical > 0)
         *  {
         *      anim.SetTrigger("AttackUpSide");
         *      //Debug.Log("Player Attacks upside right");
         *  }
         *  if (moveHorizontal == 0 && moveVertical == 1)
         *  {
         *      anim.SetTrigger("AttackUp");
         *      //Debug.Log("Player Attacks up");
         *
         *  } else
         *  {
         *      anim.SetTrigger("Attack");
         *  }
         * }
         *
         */

        /*
         *          float attackX = gameObject.transform.position.x + moveHorizontal;
         *  float attackY = gameObject.transform.position.y + moveVertical;
         *
         *   nextFire = Time.time + attackSpeed;
         *   if (moveHorizontal < 0 && moveVertical > 0)
         *   {
         *      //Debug.Log("Player Attacks Up Side left");
         *      spawnHitBox(attackX, attackY);
         *   }
         *   if (moveHorizontal == -1 || moveHorizontal == 1 && moveVertical == 0)
         *   {
         *      //Debug.Log("Player Attacks left");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  if (moveHorizontal < 0 && moveVertical < 0)
         *   {
         *      //Debug.Log("Player Down Side left");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  if (moveHorizontal == 0 && moveVertical == -1)
         *   {
         *      //Debug.Log("Player Attacks Down");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  if (moveHorizontal > 0 && moveVertical < 0)
         *   {
         *      //Debug.Log("Player Down Side right");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  if (moveHorizontal == 0 && moveVertical == 1)
         *  {
         *      //Debug.Log("Player Attacks up");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  if (moveHorizontal > 0 && moveVertical > 0)
         *  {
         *      //Debug.Log("Player Attacks upside right");
         *      spawnHitBox(attackX, attackY);
         *  }
         *  /*if (moveHorizontal == 1 && moveVertical == 0)
         *  {
         *      anim.SetTrigger("Attack");
         *      //Debug.Log("Player Attacks right");
         *  }
         *  if (moveHorizontal > 0 && moveVertical > 0)
         *  {
         *      anim.SetTrigger("AttackUpSide");
         *      //Debug.Log("Player Attacks upside right");
         *  }
         *   else
         *  {
         *      anim.SetTrigger("Attack");
         *  }*/

        /*// Find X position
         * float xx = gameObject.transform.position.x;
         * if (moveHorizontal < transform.position.x - 1f)
         * {
         *  xx -= 1f;
         * }
         * else if (moveHorizontal > transform.position.x + 1f)
         * {
         *  xx += 1f;
         * }
         *
         * // Find Y position
         * float yy = gameObject.transform.position.y;
         * if (moveVertical < transform.position.y - 1f)
         * {
         *  yy -= 1f;
         * }
         * else if (moveVertical > transform.position.y + 1f)
         * {
         *  yy += 1f;
         * }
         */

        #endregion Janne Attack
    }
コード例 #23
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #24
0
    // Fixed Update
    private void FixedUpdate()
    {
        if (isControlled == false)
        {
            // States
            switch (state)
            {
            case States.idle:
                Idle();
                break;

            case States.chase:
                Chase();
                break;

            case States.attack:
                Attack();
                break;

            case States.flee:
                Flee();
                break;

            case States.dead:
                Dead();
                break;
            }
        }
        else if (isControlled == true)
        {
            // Movement
            if (!myAttack)
            {
                float moveHorizontal = Input.GetAxisRaw("Horizontal2");
                float moveVertical   = Input.GetAxisRaw("Vertical2");
                transform.Translate(new Vector3(moveHorizontal, moveVertical) * moveSpeed * Time.deltaTime * 3);

                if (moveHorizontal > 0 && !facingRight)
                {
                    facingRight = !facingRight;
                    Vector3 theScale = transform.localScale;
                    theScale.x          *= -1;
                    transform.localScale = theScale;
                }
                else if (moveHorizontal < 0 && facingRight)
                {
                    facingRight = !facingRight;
                    Vector3 theScale = transform.localScale;
                    theScale.x          *= -1;
                    transform.localScale = theScale;
                }
            }

            // Health
            if (hitPoints <= 0)
            {
                Instantiate(deathPrefab, transform.position, transform.rotation);
                SoundManagerController.PlaySound("GoblinDeath");
                Destroy(gameObject);
            }

            // My attack
            if (Input.GetButton("Fire2") && !myAttack)
            {
                if (facingRight)
                {
                    float x2 = transform.position.x + 0.5f;
                    float y2 = transform.position.y;
                    myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                    myAttack.GetComponent <AttackController>().myEnemy = "Player";
                    SoundManagerController.PlaySound("Swish");
                }
                if (!facingRight)
                {
                    float x2 = transform.position.x - 0.5f;
                    float y2 = transform.position.y;
                    myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                    myAttack.GetComponent <AttackController>().myEnemy = "Player";
                    myAttack.GetComponent <SpriteRenderer>().flipX     = true;
                    SoundManagerController.PlaySound("Swish");
                }
            }
        }



        // Attack speed
        if (timeSinceLastAttack > 0)
        {
            timeSinceLastAttack -= Time.deltaTime;
        }

        if (damageTaken > 0)
        {
            hitPoints  -= damageTaken;
            damageTaken = 0;
            StartCoroutine("HurtColor");
            Instantiate(deathPrefab, transform.position, transform.rotation);
            SoundManagerController.PlaySound("Hit");
        }

        // Health/Death
        if (hitPoints <= 0)
        {
            state = States.dead;
        }
    }
コード例 #25
0
 // Dead if dead
 private void Dead()
 {
     Instantiate(deathPrefab, transform.position, transform.rotation);
     SoundManagerController.PlaySound("GoblinDeath");
     Destroy(gameObject);
 }
コード例 #26
0
    // Attack Otters, if they exist inside attack range
    private void Attack()
    {
        //--- Behaviour
        Debug.Log("My state is now attack");

        // Attack
        if (target && Vector2.Distance(transform.position, target.position) < attackRange)
        {
            if (!ranged && !myAttack)
            {
                // Create attack
                float x2 = target.position.x;
                float y2 = target.position.y;
                myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                myAttack.GetComponent <AttackController>().myEnemy = "Player";
                if (!facingRight)
                {
                    myAttack.GetComponent <SpriteRenderer>().flipX = true;
                }
                SoundManagerController.PlaySound("Swish");
            }
            else if (ranged && timeSinceLastAttack <= 0)
            {
                timeSinceLastAttack = attackSpeed;
                float x2 = transform.position.x;
                float y2 = transform.position.y;
                myAttack = Instantiate(attackPrefab, new Vector3(x2, y2), Quaternion.identity);
                myAttack.GetComponent <BulletController>().target = target;
                SoundManagerController.PlaySound("Gun");
            }
        }

        //--- Trigger
        if (!ranged && !myAttack)
        {
            // No Otters?
            if (!target)
            {
                state = States.idle;
            }
            // Otters too far away?
            else if (Vector2.Distance(transform.position, target.position) > attackRange)
            {
                state = States.chase;
            }
        }
        else if (ranged)
        {
            // No Otters?
            if (!target)
            {
                state = States.idle;
            }
            // Otters too far away?
            else if (Vector2.Distance(transform.position, target.position) > attackRange)
            {
                state = States.chase;
            }
            // Otters too close?
            else if (Vector2.Distance(transform.position, target.position) < fleeRange)
            {
                state = States.flee;
            }
        }

        //--- Audiovisual
        Flip();

        //state = States.idle;
    }