Exemple #1
0
    void SpawnFighter()
    {
        if (GlobalVariables.goldSaved > fightingUnitCost)
        {
            GlobalVariables.goldSaved -= fightingUnitCost;
            castleMenu.transform.Find("Panel").GetComponent <CastlePanelController>().UpdateGoldText();
            // usableMines.GetComponent<MineController>().Spend(fightingUnitCost);
            numberOfFriendlyUnits++;
            if (enemyCastleScript)
            {
                enemyCastleScript.setNumEnemyUnits(numberOfEnemyUnits + 1);
            }

            if (transform.localPosition.x > 0)
            {
                //   x_offset *= -1;
            }
            cubeSpawn = (GameObject)Instantiate(fightingUnit1, spawnSpot, Quaternion.identity);

            fighterScriptRef = cubeSpawn.GetComponent <FighterManager>();

            // cubeSpawn.transform.localPosition = new Vector3(transform.localPosition.x + x_offset, transform.localPosition.y, transform.localPosition.z);
            cubeSpawn.name             = "ThisCubeSpawn";
            cubeSpawn.transform.parent = transform;

            cubeSpawn.transform.localScale = new Vector3(.375f, .375f, .375f);
            fighterScriptRef.SetDestination(summoningZone.position);
            cubeSpawn.transform.LookAt(summoningZone);

            //   x_offset *= -1;
            // x_offset += transform.GetComponent<MeshRenderer>().bounds.extents.x*.2f;

            cubeSpawn.transform.position = new Vector3(cubeSpawn.transform.position.x + x_offset, cubeSpawn.transform.position.y, cubeSpawn.transform.position.z + z_offset);
            // z_offset += transform.GetComponent<MeshRenderer>().bounds.extents.z * .2f;
            if (transform.childCount % 5 != 0)
            {
                z_offset += cubeSpawn.GetComponent <MeshRenderer>().bounds.extents.x *1.7f;
            }
            else
            {
                z_offset  = -15 * scaleOfWorld;
                x_offset -= cubeSpawn.GetComponent <MeshRenderer>().bounds.extents.x * 1.7f;
            }

            if (transform.name == "Cube_A")
            {
                fighterScriptRef.SetEnemyBase(GameObject.Find("Cube_B").transform);
                cubeSpawn.name = "Fighter_A";
            }
            else
            {
                fighterScriptRef.SetEnemyBase(GameObject.Find("Cube_A").transform);
                cubeSpawn.name = "Fighter_B";
            }
        }
        else
        {
            Debug.Log("Not enough gold to make fighting unit");
        }
    }
Exemple #2
0
    void Awake()
    {
        _bullet         = gameObject;
        _curRigidBody   = GetComponent <Rigidbody>();
        _curTransform   = transform;
        _fighterManager = GameObject.FindObjectOfType <FighterManager> ();

        _cameraMainTransform = Camera.main.transform;
    }
Exemple #3
0
        private void CreateManagers()
        {
            _managersObject = new GameObject("Managers");

            ObjectPoolManager.CreateFromPrefab(_objectPoolManagerPrefab.gameObject, _managersObject);
            DataManager.CreateFromPrefab(_dataManagerPrefab.gameObject, _managersObject);
            GameStageManager.CreateFromPrefab(_gameStageManagerPrefab.gameObject, _managersObject);
            FighterManager.CreateFromPrefab(_fighterManagerPrefab.gameObject, _managersObject);
            AudioManager.CreateFromPrefab(_audioManagerPrefab.gameObject, _managersObject);
            PlayerManager.Create(_managersObject);
        }
    void OnCollisionStay(Collision collision)
    {
        if (collision.collider.tag == "Base")
        {
            if (!collision.gameObject.Equals(transform.parent))
            {
                ultimateDestinationReached = true;
                moving   = false;
                fighting = true;
                if (animator)
                {
                    animator.SetBool("moving", false);
                    animator.SetBool("fighting", true);
                }
                timer += Time.deltaTime;
                if (timer > 2.5f)
                {
                    enemyScriptCastleClick = collision.collider.GetComponent <CastleClick>();
                    enemyScriptCastleClick.TakeDamage(damageAmount);
                    Debug.Log("damaged castle by: " + damageAmount);
                    timer = 0;
                }
            }
        }
        else if (collision.collider.tag == "Fighter")
        {
            if (!isSibling(collision.collider.gameObject))
            {
                moving   = false;
                fighting = true;
                if (animator)
                {
                    animator.SetBool("moving", false);
                    animator.SetBool("fighting", true);
                }

                rigidbodyy.constraints = RigidbodyConstraints.FreezeAll;
                timer += Time.deltaTime;
                if (timer > 2.5f && (inArena || ultimateDestinationReached))
                {
                    enemyScriptFighterManager = collision.collider.gameObject.GetComponent <FighterManager>();
                    enemyScriptFighterManager.takeDamage(damageAmount);
                    Debug.Log("damaged other fighter by " + damageAmount);
                    timer = 0;
                }
            }
            else
            {
                //rigidbodyy.AddForce(Vector3.forward * 10, ForceMode.Force);
                transform.LookAt(destination);
                rigidbodyy.AddTorque(Vector3.forward * 2, ForceMode.Impulse);
            }
        }
    }
        static void Main(string[] args)
        {
            FighterManager box = new FighterManager();

            box.Start();
        }