Ejemplo n.º 1
0
 // Awake function gets a refernce to crab controller for controling the crab
 void Awake()
 {
     crabController         = gameObject.GetComponent <CrabController>();
     battleCloudSprite      = gameObject.GetComponentInChildren <battleAnimationScript>();
     deathCloudSprite       = gameObject.GetComponentInChildren <DeathAnimationScript>();
     this.previousTransform = this.gameObject.transform.position;
 }
Ejemplo n.º 2
0
 public void Init()
 {
     //_controlPanel = ControlPanelManager.instance.controlPanel;
     _controlPanel   = GameObject.Find("ControlPanel");
     _crab           = UtilFunction.ResourceLoad(CRAB_PREFAB_PATH);
     _crab.name      = "Crab";
     _crabController = _crab.GetComponent <CrabController>();
     _crabController.Init();
     _crabAudioController = gameObject.AddComponent <CrabAudioController>();
     _isCanCheck          = true;
 }
Ejemplo n.º 3
0
 private void ReleasCrab()
 {
     if (crabTransform != null)
     {
         crabTransform.parent = null;
         crabButtonTimer      = crabButtonCoolDown;
         CrabController cc = crabTransform.GetComponent <CrabController>();
         cc.enabled = true;
         BoxCollider2D circlC = crabTransform.GetComponent <BoxCollider2D>();
         circlC.enabled = true;
     }
     crabCaught = false;
 }
Ejemplo n.º 4
0
    ////////////////////////////////
    // Fighting related variables //
    ////////////////////////////////

    public void EnableFightMode(CrabController FightCrab)
    {
        // If the crab is not dead
        if (crabDefence > 0)
        {
            // Update the crab state
            CrabState = (int)CRAB_STATE.STATE_FIGHT;

            // Reset the fight timer
            CrabFightTimer = 0.0f;

            // Inidcate which crab is being fought
            CurrentFightCrab = FightCrab;
        }
    }
Ejemplo n.º 5
0
    public void shellPickedUp(GameObject shell)
    {
        if (this.shellsArray.Count == 0)
        {
            //shell.GetComponentInChildren<SpriteRenderer>().sortingOrder = 10 + this.shellsArray.Count;
            // Debug.Log("Picking up shell with count zero");
            //We don't have a shell yet so position it in a random rotation
            shell.transform.rotation = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.forward);
            shell.transform.position = crabShellConnectionPoint.transform.position;
            shell.transform.parent   = crabShellConnectionPoint.transform;
            shell.GetComponentInChildren <SpriteRenderer>().sortingOrder = 116;
            CrabController       tempCrabController       = gameObject.GetComponent <CrabController>();
            ShellStatsController tempShellStatsController = shell.GetComponentInChildren <ShellStatsController>();
            tempCrabController.moveSpeed   = tempCrabController.moveSpeed + tempShellStatsController.movementSpeed;
            tempCrabController.crabAttack  = tempCrabController.crabAttack + tempShellStatsController.attackDamage;
            tempCrabController.crabDefence = tempCrabController.crabDefence + tempShellStatsController.defencePoints;
            //GameObject newShell = Instantiate(shell, new Vector3(0, 0, 0), shell.transform.rotation);
            //Destroy the old shell
            //Destroy(shell);
            //Add the new shell
            this.shellsArray.Add(shell);
        }
        else if (shellsArray.Count < shellsAllowed)
        {
            // Debug.Log("Picking up shell with count non zero");
            //We don't have a shell yet so position it in a random rotation
            GameObject previousObject   = (GameObject)shellsArray[shellsArray.Count - 1];
            Quaternion previousRotation = previousObject.transform.rotation;
            shell.transform.rotation = previousRotation *= Quaternion.Euler(0, 0, 90);;
            shell.transform.position = crabShellConnectionPoint.transform.position;
            shell.transform.parent   = crabShellConnectionPoint.transform;
            shell.GetComponentInChildren <SpriteRenderer>().sortingOrder = 116;
            //Apply the stats of this shell to the crab
            CrabController       tempCrabController       = gameObject.GetComponent <CrabController>();
            ShellStatsController tempShellStatsController = shell.GetComponentInChildren <ShellStatsController>();
            tempCrabController.moveSpeed   = tempCrabController.moveSpeed + tempShellStatsController.movementSpeed;
            tempCrabController.crabAttack  = tempCrabController.crabAttack + tempShellStatsController.attackDamage;
            tempCrabController.crabDefence = tempCrabController.crabDefence + tempShellStatsController.defencePoints;

            //GameObject newShell = Instantiate(shell, new Vector3(0, 0, 0), shell.transform.rotation);
            //Destroy the old shell
            //Destroy(shell);
            //Add the new shell
            this.shellsArray.Add(shell);
        }
    }
Ejemplo n.º 6
0
    void Start()
    {
        //Get the characters
        crab = GameObject.Find("CrabCharacter").GetComponent <CrabController>();
        duck = GameObject.Find("Duck").GetComponent <DuckController>();

        //Find the duckHealth images
        duckHealth1 = transform.GetChild(0).GetChild(1).GetComponent <Image>();
        duckHealth2 = transform.GetChild(0).GetChild(3).GetComponent <Image>();
        duckHealth3 = transform.GetChild(0).GetChild(5).GetComponent <Image>();


        //Find the crabhealth images
        crabHealth1 = transform.GetChild(1).GetChild(1).GetComponent <Image>();
        crabHealth2 = transform.GetChild(1).GetChild(3).GetComponent <Image>();
        crabHealth3 = transform.GetChild(1).GetChild(5).GetComponent <Image>();

        timerText = transform.GetChild(2).GetComponent <Text>();
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = cam.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
        RaycastHit hit;

        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit))
            {
                CrabController enemy = hit.transform.GetComponent <CrabController>();
                if (enemy)
                {
                    enemy.Damage(damage);
                }
            }
            else
            {
                hit.point = cam.transform.position + (ray.direction * 10);
            }
            fire(hit.point);
        }

        //**********Gun originally pointed where you looked, animation breaks this fix later

        /*
         * if (Physics.Raycast(ray, out hit)) {
         *  gun.transform.LookAt(hit.point);
         *
         *  if (Input.GetMouseButtonDown(0)) {
         *      CrabController enemy = hit.transform.GetComponent<CrabController>();
         *      if (enemy) {
         *          enemy.Damage(damage);
         *      }
         *      fire(hit.point);
         *  }
         * }
         */
    }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     qwe();
     crabController = GetComponent <CrabController>();
 }
Ejemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     if (!inDiving)
     {
         if (Input.GetAxisRaw("Fire1") > 0)
         {
             keepDiving = true;
             if (!inDiving)
             {
                 StartCoroutine(DivingRoutine(diveDepth, new Vector3((float)horizontalSpeed, (float)verticalSpeed, 0)));
                 if (animator != null)
                 {
                     animator.SetBool("isDiving", true);
                 }
                 inDiving = true;
             }
         }
         if (Input.GetAxisRaw("Fire2") > 0 && (shotCoolDown == 0))
         {
             if (pewSound != null)
             {
                 pewSound.Play();
             }
             GameObject go  = Instantiate(duckShotResource) as GameObject;
             Vector3    tmp = collider.bounds.center;
             tmp.x = collider.bounds.max.x + go.GetComponent <Collider2D>().bounds.size.x;
             go.transform.position = tmp;
             DuckShotController dsc = go.GetComponent <DuckShotController>();
             dsc.enabled           = true;
             dsc.movementDirection = transform.right;
             shotCoolDown          = shotDisableFrames;
         }
     }
     else
     {
         if (Input.GetAxisRaw("Fire1") <= 0)
         {
             if (animator != null)
             {
                 animator.SetBool("isDiving", false);
             }
             keepDiving = false;
         }
     }
     if (Input.GetAxisRaw("Fire3") > 0)
     {
         if (!crabCaught && crabButtonTimer == 0)
         {
             float   distance;
             Vector3 rayDirection, rayJump, startPos;
             CalculateNecesaryValues(15, RayDirectionSearch.DOWN, collider.bounds, collider.bounds.size.y, 0, transform, false, out distance, out rayDirection, out rayJump, out startPos);
             Vector3      moveVector;
             RaycastHit2D tmp;
             RaycastHit2D rh = DoRaycast(15, RayDirectionSearch.DOWN, distance, rayDirection, rayJump, startPos, out moveVector, out tmp, "Crab");
             if (rh.collider != null)
             {
                 rh.collider.transform.parent   = transform;
                 rh.collider.transform.position = crabPos.position;
                 crabTransform = rh.collider.transform;
                 CrabController cc = crabTransform.GetComponent <CrabController>();
                 cc.enabled = false;
                 BoxCollider2D circlC = crabTransform.GetComponent <BoxCollider2D>();
                 circlC.enabled = false;
                 Debug.Log("Doing the GRAB FFS");
                 crabCaught      = true;
                 crabCaughtTimer = crabCaughtMaxHoldTime;
             }
             crabButtonTimer = crabButtonCoolDown;
         }
         else if (crabButtonTimer == 0)
         {
             ReleasCrab();
         }
     }
     if (crabCaught && crabCaughtTimer == 0)
     {
         ReleasCrab();
     }
     if (shotCoolDown > 0)
     {
         shotCoolDown--;
     }
     if (crabButtonTimer > 0)
     {
         crabButtonTimer--;
     }
     if (crabCaughtTimer > 0)
     {
         crabCaughtTimer--;
     }
     // Update invincibility counter n' stuff
     invincibility.Update();
 }