Exemplo n.º 1
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (explosion1 == null)
        {
            explosion1 = transform.Find("ui-map-explosion-1").gameObject;
            explosion2 = transform.Find("ui-map-explosion-2").gameObject;
        }

        if (!isInitialized)
        {
            isInitialized = true;

            int levelCount = 1;
            levelButtonsList = new List <GameObject> ();
            levelLocksList   = new List <GameObject> ();
            foreach (GameObject level in this.tcScript.levelsList)
            {
                GameObject levelButtonGameObject = transform.Find("Level" + levelCount + "Button").gameObject;
                levelButtonsList.Add(levelButtonGameObject);
                GameObject levelLockGameObject = transform.Find("Level" + levelCount + "Button/Lock").gameObject;
                levelLocksList.Add(levelLockGameObject);
                levelCount++;
            }
        }
    }
Exemplo n.º 2
0
    // The Awake function is called on all objects in the scene before any object's Start function is called.
    void Awake()
    {
        // Store UI elements for later access

        Camera mainCamera = Camera.main;

        this.tcScript = mainCamera.GetComponent <TacticalCombat> ();

        debugHealthText          = GameObject.Find("HealthText");
        debugAttackText          = GameObject.Find("AttackText");
        debugFirerateText        = GameObject.Find("FirerateText");
        debugProjectileSpeedText = GameObject.Find("ProjectileSpeedText");
        debugRangeText           = GameObject.Find("RangeText");
        debugSpeedText           = GameObject.Find("SpeedText");
        debugMeleeText           = GameObject.Find("MeleeText");

        debugHealthValue          = GameObject.Find("HealthValue");
        debugAttackValue          = GameObject.Find("AttackValue");
        debugFirerateValue        = GameObject.Find("FirerateValue");
        debugProjectileSpeedValue = GameObject.Find("ProjectileSpeedValue");
        debugRangeValue           = GameObject.Find("RangeValue");
        debugSpeedValue           = GameObject.Find("SpeedValue");
        debugMeleeValue           = GameObject.Find("MeleeValue");

        //		debugHealthSlider = GameObject.Find ("HealthSlider");
        //		debugAttackSlider = GameObject.Find ("AttackSlider");
        //		debugFirerateSlider = GameObject.Find ("FirerateSlider");
        //		debugProjectileSpeedSlider = GameObject.Find ("ProjectileSpeedSlider");
        //		debugRangeSlider = GameObject.Find ("RangeSlider");
        //		debugSpeedSlider = GameObject.Find ("SpeedSlider");
        //		debugMeleeSlider = GameObject.Find ("MeleeSlider");

        debugEnableAIToggle = GameObject.Find("EnableAIToggle");
        debugResetButton    = GameObject.Find("ResetButton");
    }
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (unitProfilePicBZ == null)
        {
            unitProfilePicBZ = transform.Find("UnitSelectionProfileBZ").gameObject;
            unitProfilePicFT = transform.Find("UnitSelectionProfileFT").gameObject;
            unitProfilePicGL = transform.Find("UnitSelectionProfileGL").gameObject;
            unitProfilePicGR = transform.Find("UnitSelectionProfileGR").gameObject;
            unitProfilePicMG = transform.Find("UnitSelectionProfileMG").gameObject;
            unitNameBZ       = transform.Find("UnitSelectionNameBZ").gameObject;
            unitNameFT       = transform.Find("UnitSelectionNameFT").gameObject;
            unitNameGL       = transform.Find("UnitSelectionNameGL").gameObject;
            unitNameGR       = transform.Find("UnitSelectionNameGR").gameObject;
            unitNameMG       = transform.Find("UnitSelectionNameMG").gameObject;
            level1           = transform.Find("Level1").gameObject;
            level2           = transform.Find("Level2").gameObject;
            level3           = transform.Find("Level3").gameObject;
            statValuesText   = transform.Find("StatValuesText").gameObject;
            armorHealthText  = transform.Find("ArmorHealthText").gameObject;

            ClearButton();
        }
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        Camera mainCamera = Camera.main;

        this.tcScript = mainCamera.GetComponent <TacticalCombat> ();

        this.inventoryItemList = new List <InventoryItem> ();
    }
Exemplo n.º 5
0
 void InitializeIfNeeded()
 {
     if (this.tcScript == null)
     {
         Camera mainCamera = Camera.main;
         this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
     }
 }
Exemplo n.º 6
0
    // The Awake function is called on all objects in the scene before any object's Start function is called.
    void Awake()
    {
        Camera mainCamera = Camera.main;

        this.tcScript = mainCamera.GetComponent <TacticalCombat> ();

        rewardText  = transform.Find("RewardText").gameObject;
        retryButton = transform.Find("RetryButton").gameObject;
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        Utilities.DebugLog("Projectile.Start ()");
        Camera mainCamera = Camera.main;

        this.tcScript               = mainCamera.GetComponent <TacticalCombat> ();
        this.nonAdjustedPosition    = this.gameObject.transform.position;
        this.timeAtStart            = (float)Time.time;
        this.timeAtDestroy          = 0;
        this.isWaitingToBeDestroyed = false;
    }
Exemplo n.º 8
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (!isInitialized)
        {
            isInitialized = true;

            UpdatePanelForLevel(this.tcScript.currentLevel);
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        Utilities.DebugLog("TerrainObstacle.Start ()");
        // Enable/disable pathfinding obstruction
        PolyNavObstacle polyNavObstacle = this.gameObject.GetComponent <PolyNavObstacle> ();

        if (polyNavObstacle)
        {
            polyNavObstacle.enabled = this.shouldStopUnitMovementWhenIntact;
        }

        Camera mainCamera = Camera.main;

        this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
    }
Exemplo n.º 10
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (!isInitialized)
        {
            isInitialized = true;

            // Create 5 buttons
            this.selectedUnitButtonList = new List <GameObject> ();
            for (int i = 0; i < 5; i++)
            {
                GameObject selectedUnitButton = (GameObject)Instantiate(this.selectedUnitButtonPrefab, Vector3.zero, Quaternion.identity);
                selectedUnitButton.transform.parent = this.transform;
                RectTransform rectTransform = selectedUnitButton.GetComponent <RectTransform> ();
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 528 + 50 * i, 387.0f);
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1181 /*337*/, 454.0f);
                //selectedUnitButton.transform.position = new Vector3 (-738 + 360 * i, -143, 0);
                float scaleMultiplier = 0.09f;
                selectedUnitButton.transform.localScale = new Vector3(scaleMultiplier, scaleMultiplier, scaleMultiplier);

                Button selectedUnitButtonScript = selectedUnitButton.GetComponent <Button> ();
                selectedUnitButtonScript.onClick.AddListener(delegate {
                    SelectedUnitButton_Tapped(selectedUnitButton);
                });

                this.selectedUnitButtonList.Add(selectedUnitButton);
            }


            SetupLevelScreenshotsListIfNeeded();
        }

        if (this.easyCheckboxOn == null)
        {
            easyCheckboxOn    = transform.Find("EasyCheckboxOn").gameObject;
            mediumCheckboxOn  = transform.Find("MediumCheckboxOn").gameObject;
            hardCheckboxOn    = transform.Find("HardCheckboxOn").gameObject;
            easyCheckboxOff   = transform.Find("EasyCheckboxOff").gameObject;
            mediumCheckboxOff = transform.Find("MediumCheckboxOff").gameObject;
            hardCheckboxOff   = transform.Find("HardCheckboxOff").gameObject;
        }
    }
Exemplo n.º 11
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (!isInitialized)
        {
            isInitialized = true;

            this.selectedUnitButtonList = new List <GameObject> ();
            // Create 5 buttons
            for (int i = 0; i < 5; i++)
            {
                GameObject selectedUnitButton = (GameObject)Instantiate(this.selectedUnitButtonPrefab, Vector3.zero, Quaternion.identity);
                selectedUnitButton.transform.parent = this.transform;
                RectTransform rectTransform = selectedUnitButton.GetComponent <RectTransform> ();
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 90 + 400 * i, 387.0f);
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 370, 454.0f);
                //selectedUnitButton.transform.position = new Vector3 (-738 + 360 * i, -143, 0);
                selectedUnitButton.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);

                Button selectedUnitButtonScript = selectedUnitButton.GetComponent <Button> ();
                selectedUnitButtonScript.onClick.AddListener(delegate {
                    SelectedUnitButton_Tapped(selectedUnitButton);
                });

                this.selectedUnitButtonList.Add(selectedUnitButton);
            }
        }

        if (team1Tab == null)
        {
            team1Tab = transform.Find("Team1Tab").gameObject;
            team2Tab = transform.Find("Team2Tab").gameObject;
            team3Tab = transform.Find("Team3Tab").gameObject;
        }
    }
Exemplo n.º 12
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (unitProfilePicBZ == null)
        {
            unitProfilePicBZ = transform.Find("UnitProfilePicBZ").gameObject;
            unitProfilePicFT = transform.Find("UnitProfilePicFT").gameObject;
            unitProfilePicGL = transform.Find("UnitProfilePicGL").gameObject;
            unitProfilePicGR = transform.Find("UnitProfilePicGR").gameObject;
            unitProfilePicMG = transform.Find("UnitProfilePicMG").gameObject;
            level1           = transform.Find("Level1").gameObject;
            level2           = transform.Find("Level2").gameObject;
            level3           = transform.Find("Level3").gameObject;
            closeButtonImage = transform.Find("CloseButtonImage").gameObject;

            ClearButton();
        }
    }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        if (tcScript.isLevelComplete || tcScript.isLevelFailed || tcScript.isMenuOpen)
        {
            return;
        }

        if (this.isWaitingToBeDestroyed)
        {
            TrailRenderer trailRenderer = this.gameObject.GetComponent <TrailRenderer> ();
            if (trailRenderer)
            {
                float currentTime      = (float)Time.time;
                float timeSinceDestroy = currentTime - timeAtDestroy;
                float t        = Mathf.Min(1.0f, timeSinceDestroy / 1.0f + 0.5f);
                Color newColor = Color.Lerp(Color.white, Color.clear, t);
                trailRenderer.material.SetColor("_TintColor", newColor);
            }
            return;
        }

        Utilities.DebugLog("Projectile.Update ()");
        if (this.currentState == ProjectileState.PROJECTILE_STATE_ACTIVE)
        {
            Utilities.DebugLog("AdjustedDistance () 1111111");
            this.distanceTravelled = TacticalCombat.AdjustedDistance(this.basePosition, this.initialPosition);
            this.percentTravelled  = this.distanceTravelled / this.range;

            if (this.isBallisticProjectile)
            {
                this.basePosition = new Vector2(this.basePosition.x + this.direction.x * this.speed * Time.deltaTime, this.basePosition.y + this.direction.y * this.speed * TacticalCombat.VERTICAL_SQUASH_RATIO * Time.deltaTime);

                if (this.isBouncingProjectile && percentTravelled != 0)
                {
                    this.ballisticShift = Mathf.Abs(Mathf.Sin(Mathf.PI * this.distanceTravelled * this.distanceTravelled * this.distanceTravelled / (this.range * this.range * this.range)) / (this.distanceTravelled * this.distanceTravelled) * (0.55f * this.range * this.range));
                }
                else
                {
                    this.ballisticShift = Mathf.Sin(Mathf.PI * percentTravelled) * ((18.0f /*900.0f*/ - this.range) / 10.0f /*500.0f*/);
                }
                this.fullBallisticShift = this.ballisticShift * this.ballisticHeight;
                //Utilities.DebugLog ("ballistic shift = " + fullBallisticShift + ", basePosition.y = " + this.basePosition.y);

                Vector2 oldPosition = this.gameObject.transform.position;
                Vector2 newPosition = new Vector2(this.basePosition.x, this.basePosition.y + this.fullBallisticShift);

                // Rotate Grenade Launcher projectile to face its current direction in arc
                if (this.isGrenadeLauncher)
                {
                    Vector3    vectorToTarget = new Vector3(newPosition.x - oldPosition.x, newPosition.y - oldPosition.y, 0);
                    float      angle          = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg;
                    Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
                    targetRotation = q;
                    this.gameObject.transform.rotation = Quaternion.Lerp(this.gameObject.transform.rotation, targetRotation, 0.5f);
                }

                this.gameObject.transform.position = newPosition;
            }
            else if (this.isBazooka)
            {
                float currentTime    = (float)Time.time;
                float timeSinceStart = currentTime - timeAtStart;
                float t = Mathf.Min(1.0f, timeSinceStart / 2.0f);
                t = 10.0f * t * t * t * t;
                float bazookaSpeed = Mathf.Lerp(0.2f * this.speed, 1.6f * this.speed, t);
                this.basePosition = new Vector2(this.basePosition.x + this.direction.x * bazookaSpeed * Time.deltaTime, this.basePosition.y + this.direction.y * bazookaSpeed * TacticalCombat.VERTICAL_SQUASH_RATIO * Time.deltaTime);
                this.gameObject.transform.position = this.basePosition;
            }
            else
            {
                this.basePosition = new Vector2(this.basePosition.x + this.direction.x * this.speed * Time.deltaTime, this.basePosition.y + this.direction.y * this.speed * TacticalCombat.VERTICAL_SQUASH_RATIO * Time.deltaTime);
                this.gameObject.transform.position = this.basePosition;
            }

            if (this.isBouncingProjectile)
            {
                if (this.distanceTravelled > 1.5f * this.range)
                {
                    DestroyProjectileAccordingToType();
                }
            }
            else
            {
                if (this.distanceTravelled > this.range)
                {
                    DestroyProjectileAccordingToType();
                }
            }
        }
    }
Exemplo n.º 14
0
    void InitializeIfNeeded()
    {
        if (this.tcScript == null)
        {
            Camera mainCamera = Camera.main;
            this.tcScript = mainCamera.GetComponent <TacticalCombat> ();
        }

        if (selectedUnitDataObject == null)
        {
            selectedUnitDataObject = this.tcScript.unitDataObjectsList [0];
        }

        if (unitDetailSubpanel == null)
        {
            unitDetailSubpanel = transform.Find("UnitDetailSubpanel").gameObject;

            characterTab = unitDetailSubpanel.transform.Find("CharacterTab").gameObject;
            weaponTab    = unitDetailSubpanel.transform.Find("WeaponTab").gameObject;
            armorTab     = unitDetailSubpanel.transform.Find("ArmorTab").gameObject;

            characterUpgradingText  = characterTab.transform.Find("CharacterUpgradingText").gameObject;
            characterLevelValueText = characterTab.transform.Find("CharacterLevelValueText").gameObject;
            characterLevelLabelText = characterTab.transform.Find("CharacterLevelLabelText").gameObject;
            unitProfilePicBZ        = characterTab.transform.Find("UnitProfilePicBZ").gameObject;
            unitProfilePicFT        = characterTab.transform.Find("UnitProfilePicFT").gameObject;
            unitProfilePicGL        = characterTab.transform.Find("UnitProfilePicGL").gameObject;
            unitProfilePicGR        = characterTab.transform.Find("UnitProfilePicGR").gameObject;
            unitProfilePicMG        = characterTab.transform.Find("UnitProfilePicMG").gameObject;

            weaponUpgradingText  = weaponTab.transform.Find("WeaponUpgradingText").gameObject;
            weaponLevelValueText = weaponTab.transform.Find("WeaponLevelValueText").gameObject;
            weaponLevelLabelText = weaponTab.transform.Find("WeaponLevelLabelText").gameObject;
            weaponIcon           = weaponTab.transform.Find("WeaponIcon").gameObject;

            armorUpgradingText  = armorTab.transform.Find("ArmorUpgradingText").gameObject;
            armorLevelValueText = armorTab.transform.Find("ArmorLevelValueText").gameObject;
            armorLevelLabelText = armorTab.transform.Find("ArmorLevelLabelText").gameObject;
            armorIcon           = armorTab.transform.Find("ArmorIcon").gameObject;

            statValuesText     = unitDetailSubpanel.transform.Find("StatValuesText").gameObject;
            statLabelsText     = unitDetailSubpanel.transform.Find("StatLabelsText").gameObject;
            statButton1        = unitDetailSubpanel.transform.Find("StatButton1").gameObject;
            statButton2        = unitDetailSubpanel.transform.Find("StatButton2").gameObject;
            statButton3        = unitDetailSubpanel.transform.Find("StatButton3").gameObject;
            characterTabButton = unitDetailSubpanel.transform.Find("CharacterTabButton").gameObject;
            weaponTabButton    = unitDetailSubpanel.transform.Find("WeaponTabButton").gameObject;
            armorTabButton     = unitDetailSubpanel.transform.Find("ArmorTabButton").gameObject;
            upgradeButton      = unitDetailSubpanel.transform.Find("UpgradeButton").gameObject;
            addToTeamButton    = unitDetailSubpanel.transform.Find("AddToTeamButton").gameObject;
        }

        if (unitSelectionScrollViewContent == null)
        {
            unitSelectionScrollViewContent = GameObject.Find("UnitSelectionScrollViewContent");
        }

        if (!isInitialized && unitSelectionScrollViewContent != null)
        {
            isInitialized = true;

            this.unitSelectionTabButtonList = new List <GameObject> ();
            // Create buttons for each unit
            for (int i = 0; i < tcScript.unitDataObjectsList.Count; i++)
            {
                UnitDataObject unitDataObject         = tcScript.unitDataObjectsList [i];
                GameObject     unitSelectionTabButton = (GameObject)Instantiate(this.unitSelectionTabButtonPrefab, Vector3.zero, Quaternion.identity);

                unitSelectionTabButton.transform.parent = unitSelectionScrollViewContent.transform;
                RectTransform rectTransform = unitSelectionTabButton.GetComponent <RectTransform> ();
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, -400, 1320.0f /* * 0.25f*/);
                rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, -150 - 18 + 120 * i * 0.75f, 432.0f /* * 0.25f*/);
                unitSelectionTabButton.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);

                UnitSelectionTabButton unitSelectionTabButtonScript = unitSelectionTabButton.GetComponent <UnitSelectionTabButton> ();
                unitSelectionTabButtonScript.SetUnitDataObject(unitDataObject);

                Button tappableButtonScript = unitSelectionTabButton.GetComponent <Button> ();
                tappableButtonScript.onClick.AddListener(delegate {
                    SelectedUnitButton_Tapped(unitSelectionTabButton);
                });

                this.unitSelectionTabButtonList.Add(unitSelectionTabButton);
            }

            // Set scrollview content size based on number of units
            RectTransform contentViewRectTransform = unitSelectionScrollViewContent.GetComponent <RectTransform> ();
            contentViewRectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 1320.0f /* * 0.25f*/);
            contentViewRectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 120.0f * tcScript.unitDataObjectsList.Count * 0.75f * 1.01f);
        }
    }