示例#1
0
    public void ModeButtonClicked()
    {
        AllySpaceship allyS = SpaceshipManager.instance.selectedSpaceship.GetComponent <AllySpaceship>();

        allyS.SwitchMode();
        UpdateModeDisplay();
    }
    public void UpdateExperienceBar()
    {
        if (experienceBarBackground != null && experienceBar != null)
        {
            AllySpaceship allyS = spaceship.GetComponent <AllySpaceship>();
            float         nextLevelExperiencePoints = (allyS.level < 3) ? allyS.spaceshipType.levelExperiencePointLimits[allyS.level - 1] : allyS.experiencePoints;
            float         experiencePoints          = spaceship.GetComponent <AllySpaceship>().experiencePoints;
            float         experienceRatio           = experiencePoints / nextLevelExperiencePoints;

            RectTransform experiencePointsBarRectTransform = experienceBar.GetComponent <RectTransform>();
            experiencePointsBarRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 130 * experienceRatio);
        }
    }
    public SpaceshipData[] BuildSpaceshipsData()
    {
        int spaceshipsNb = allySpaceships.Count;

        Debug.Log("BuildSpaceshipsData | Nb: " + spaceshipsNb);
        spaceshipsData = new SpaceshipData[spaceshipsNb];

        for (int i = 0; i < allySpaceships.Count; i++)
        {
            AllySpaceship allyS = allySpaceships[i].GetComponent <AllySpaceship>();
            spaceshipsData[i] = (new SpaceshipData(allyS.spaceshipType.index, new GeometryManager.Position(allySpaceships[i].transform.position), allyS.level, allyS.experiencePoints));
            Debug.Log("Adding spaceship [" + i + "] | TypeIndex [" + allyS.spaceshipType.index + "] | Level [" + allyS.level + "] | Exp [" + allyS.experiencePoints + "]");
        }

        return(spaceshipsData);
    }
    public void SpawnSpaceshipOfType(SpaceshipType spaceshipType)
    {
        Debug.Log("SpawnSpaceshipOfType [" + spaceshipType.typeName + "]");

        GameObject instantiatedSpaceship = Instantiate(spaceshipType.prefab, newGameSpaceshipPosition.transform.position, Quaternion.Euler(0, 90, 0));

        // Set attributes
        AllySpaceship spaceship = instantiatedSpaceship.GetComponent <AllySpaceship>();

        spaceship.Initialize();
        spaceship.SetSpaceshipType(spaceshipType);
        spaceship.homeSpaceport = null;

        instantiatedSpaceship.transform.SetParent(spaceshipsParent);

        AddAlliedSpaceshipToList(instantiatedSpaceship);
        UpdateFleetPointsInfo();
    }
    public GameObject SpawnSpaceshipTypeAtPos(SpaceshipType sType, GeometryManager.Position pos)
    {
        //Debug.Log("Spawning saved spaceship");
        GameObject instantiatedSpaceship = Instantiate(sType.prefab, new Vector3(pos.x, pos.y, pos.z), Quaternion.identity);

        // Attribute ID to spaceship
        AllySpaceship allyS = instantiatedSpaceship.GetComponent <AllySpaceship>();

        allyS.Initialize();
        allyS.id            = GetAvailableSpaceshipId();
        allyS.spaceshipType = sType;

        AddAlliedSpaceshipToList(instantiatedSpaceship);

        instantiatedSpaceship.transform.SetParent(spaceshipsParent.transform);

        UpdateFleetPointsInfo();

        return(instantiatedSpaceship);
    }
示例#6
0
    public void UpdateModeDisplay()
    {
        GameObject selectedS = SpaceshipManager.instance.selectedSpaceship;

        if (selectedS != null)
        {
            AllySpaceship allyS = selectedS.GetComponent <AllySpaceship>();
            if (allyS != null)
            {
                if (allyS.isInAutomaticMode)
                {
                    modeButtonText.text = "AUTO";
                    modePanel.GetComponent <Image>().color = autoModeColor;
                }
                else
                {
                    modeButtonText.text = "MANUAL";
                    modePanel.GetComponent <Image>().color = manualModeColor;
                }
            }
        }
    }
示例#7
0
    public void UpdateInfo()
    {
        GameObject selectedSpaceship = SpaceshipManager.instance.selectedSpaceship;

        if (selectedSpaceship != null)
        {
            AllySpaceship allyS = selectedSpaceship.GetComponent <AllySpaceship>();
            if (allyS != null)
            {
                //Debug.Log("Update Spaceship panel info");
                UpdateHealthInfo(allyS);
                UpdateShieldInfo(allyS);
                UpdateModeDisplay();
                SetSpaceshipImage(allyS);
                SetSpaceshipTypeText(allyS);
            }
        }
        else
        {
            //Debug.Log("SetInfo: No selected Spaceship !");
        }
    }
    public GameObject SpawnSavedSpaceship(SpaceshipData sData)
    {
        //Debug.Log("Spawning saved spaceship");
        GameObject instantiatedSpaceship = Instantiate(GetSpaceshipTypeByIndex(sData.spaceshipTypeIndex).prefab, new Vector3(sData.position.x, sData.position.y, sData.position.z), Quaternion.identity);

        // Attribute ID to spaceship
        AllySpaceship allyS = instantiatedSpaceship.GetComponent <AllySpaceship>();

        allyS.Initialize();
        allyS.id               = GetAvailableSpaceshipId();
        allyS.spaceshipType    = GetSpaceshipTypeByIndex(sData.spaceshipTypeIndex);
        allyS.level            = sData.level;
        allyS.experiencePoints = sData.experiencePoints;

        AddAlliedSpaceshipToList(instantiatedSpaceship);

        instantiatedSpaceship.transform.SetParent(spaceshipsParent.transform);

        UpdateFleetPointsInfo();

        return(instantiatedSpaceship);
    }
    public void UpdateInfo()
    {
        if (spaceship.GetComponent <AllySpaceship>() != null)
        {
            AllySpaceship alliedSpaceship = spaceship.GetComponent <AllySpaceship>();

            spaceshipTypeText.text    = spaceship.GetComponent <AllySpaceship>().spaceshipType.typeName.ToString();
            healthPointsText.text     = alliedSpaceship.healthPoints.ToString();
            maxHealthPointsText.text  = alliedSpaceship.maxHealthPoints.ToString();
            shieldPointsText.text     = alliedSpaceship.shieldPoints.ToString();
            maxShieldPointsText.text  = alliedSpaceship.maxShieldPoints.ToString();
            experiencePointsText.text = alliedSpaceship.experiencePoints.ToString();

            spaceshipImage.sprite = alliedSpaceship.spaceshipType.sprite;

            nextLevelexperiencePointsText.text = (alliedSpaceship.level < 3 /* USE A VARIABLE HERE */) ? (alliedSpaceship.spaceshipType.levelExperiencePointLimits[alliedSpaceship.level - 1].ToString()) : " - ";
            fleetPointsUsedText.text           = alliedSpaceship.spaceshipType.fleetPointsNeeded.ToString();

            UpdateShieldBar();
            UpdateHealthBar();
            UpdateExperienceBar();
            UpdateStarsImage();
        }
    }
示例#10
0
 void UpdateShieldInfo(AllySpaceship allyS)
 {
     SetShieldText((int)allyS.shieldPoints, (int)allyS.maxShieldPoints);
 }
示例#11
0
 void UpdateHealthInfo(AllySpaceship allyS)
 {
     SetHealthText((int)allyS.healthPoints, (int)allyS.maxHealthPoints);
 }
示例#12
0
 void SetSpaceshipImage(AllySpaceship allyS)
 {
     spaceshipImage.sprite = allyS.spaceshipType.sprite;
 }
示例#13
0
 void SetSpaceshipTypeText(AllySpaceship allyS)
 {
     spaceshipTypeText.text = allyS.spaceshipType.typeName;
 }