Ejemplo n.º 1
0
    public void AddToList(SpaceObject spaceObject)
    {
        string type = spaceObject.GetObjectType();

        m_AllSpaceObjects.Add(spaceObject);
        if (type == "Decor")
        {
            m_AllDecorObjects.Add(spaceObject);
        }
        else if (type == "Ship")
        {
            m_AllShips.Add(spaceObject);
            HUD.Instance.SpawnMarker(spaceObject);
            string faction = spaceObject.GetFaction();
            string size    = spaceObject.GetSize();
            if (faction == "Player")
            {
                m_PlayerShips.Add(spaceObject);
                if (size == "Small")
                {
                    m_PlayerSmallShips.Add(spaceObject);
                }
                else if (size == "Large")
                {
                    m_PlayerLargeShips.Add(spaceObject);
                }
                else
                {
                    Debug.LogError("invalid argument");
                }
            }
            else if (faction == "Enemy")
            {
                m_EnemyShips.Add(spaceObject);
                if (size == "Small")
                {
                    m_EnemySmallShips.Add(spaceObject);
                }
                else if (size == "Large")
                {
                    m_EnemyLargeShips.Add(spaceObject);
                }
                else
                {
                    Debug.LogError("invalid size argument");
                }
            }
            else
            {
                Debug.LogError("invalid faction argument");
                Debug.Log("faction = " + faction);
            }
        }
        else
        {
            Debug.LogError("invalid argument : " + type);
        }
    }
Ejemplo n.º 2
0
    public void SpawnTargetMarker(SpaceObject ship)
    {
        string     spaceObjectFaction = ship.GetFaction();
        GameObject markerPrefab       = Resources.Load <GameObject>("Prefab/HUD/TargetMarker");
        GameObject markerInstance     = Instantiate(markerPrefab, ship.GetBody().transform.position, Quaternion.identity) as GameObject;

        markerInstance.GetComponent <Marker>().SetSpaceObject(ship);
        markerInstance.transform.SetParent(GameObject.Find("HUD/Markers/TargetMarkers").transform);
    }
Ejemplo n.º 3
0
    public void RemoveToList(SpaceObject spaceObject)
    {
        string type = spaceObject.GetObjectType();

        m_AllSpaceObjects.Remove(spaceObject);
        if (type == "Decor")
        {
            m_AllDecorObjects.Remove(spaceObject);
        }
        else if (type == "Ship")
        {
            m_AllShips.Remove(spaceObject);
            string faction = spaceObject.GetFaction();
            string size    = spaceObject.GetSize();
            if (faction == "Player")
            {
                m_PlayerShips.Remove(spaceObject);
                if (size == "Small")
                {
                    m_PlayerSmallShips.Remove(spaceObject);
                }
                else if (size == "Large")
                {
                    m_PlayerLargeShips.Remove(spaceObject);
                }
                else
                {
                    Debug.LogError("invalid argument");
                }
            }
            else if (faction == "Enemy")
            {
                m_EnemyShips.Remove(spaceObject);
                if (size == "Small")
                {
                    m_EnemySmallShips.Remove(spaceObject);
                }
                else if (size == "Large")
                {
                    m_EnemyLargeShips.Remove(spaceObject);
                }
                else
                {
                    Debug.LogError("invalid argument");
                }
            }
            else
            {
                Debug.LogError("invalid argument");
            }
        }
        else
        {
            Debug.LogError("invalid argument");
        }
    }
Ejemplo n.º 4
0
    private void ConfigureColor()
    {
        Color  markerColor = new Color();
        string faction     = m_SpaceObject.GetFaction();

        if (faction == "Player")
        {
            markerColor = new Color(0, 255, 0, 1);
        }
        else if (faction == "Enemy")
        {
            markerColor = new Color(255, 0, 0, 1);
        }
        else if (faction == "Neutral")
        {
            markerColor = new Color(255, 255, 0, 1);
        }
        else
        {
            markerColor = new Color(255, 0, 0, 1);
        }

        transform.GetComponent <Image> ().color = markerColor;
    }
Ejemplo n.º 5
0
 public bool ValidTargetFaction(SpaceObject target)
 {
     if (m_TargetFaction == "Other" && target.GetComponent <SpaceObject> ().GetObjectType() == "Decor")
     {
         return(true);
     }
     if ((m_TargetFaction == "Same" && target.GetComponent <SpaceObject> ().GetFaction() == m_SpaceObject.GetFaction()) ||
         (m_TargetFaction == "Other" && target.GetComponent <SpaceObject> ().GetFaction() != m_SpaceObject.GetFaction()) ||
         (m_TargetFaction == "Self" && target.gameObject == m_SpaceObject))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 public void AddSpaceObject(SpaceObject spaceObject)
 {
     if (spaceObject.GetFaction() == "Player")
     {
         m_PlayerShips.Add(spaceObject);
         if (spaceObject.GetSize() == "Small")
         {
             m_PlayerSmallShips.Add(spaceObject);
             if (spaceObject.GetClass() == "Interceptor")
             {
                 m_PlayerInterceptors.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "HeavyAssault")
             {
                 m_PlayerHeavyAssault.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Lancer")
             {
                 m_PlayerLancer.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Support")
             {
                 m_PlayerSupport.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Bomber")
             {
                 m_PlayerBomber.Add(spaceObject);
             }
             else
             {
                 Debug.LogError("invalid class : " + spaceObject.GetClass() + " for space object : " + spaceObject.gameObject.name);
             }
         }
         else if (spaceObject.GetSize() == "Large")
         {
             m_PlayerLargeShips.Add(spaceObject);
             if (spaceObject.GetClass() == "AssaultFregate")
             {
                 m_PlayerAssaultFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "ArtilleryFregate")
             {
                 m_PlayerArtilleryFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "SupportFregate")
             {
                 m_PlayerSupportFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "AntiFighterFregate")
             {
                 m_PlayerAntiFighterFregate.Add(spaceObject);
             }
             else
             {
                 Debug.LogError("invalid class : " + spaceObject.GetClass() + " for space object : " + spaceObject.gameObject.name);
             }
         }
         else
         {
             Debug.LogError("invalid size : " + spaceObject.GetSize() + " for space object : " + spaceObject.gameObject.name);
         }
     }
     else if (spaceObject.GetFaction() == "Enemy")
     {
         m_EnemyShips.Add(spaceObject);
         if (spaceObject.GetSize() == "Small")
         {
             m_EnemySmallShips.Add(spaceObject);
             if (spaceObject.GetClass() == "Interceptor")
             {
                 m_EnemyInterceptors.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "HeavyAssault")
             {
                 m_EnemyHeavyAssault.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Lancer")
             {
                 m_EnemyLancer.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Support")
             {
                 m_EnemySupport.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "Bomber")
             {
                 m_EnemyBomber.Add(spaceObject);
             }
             else
             {
                 Debug.LogError("invalid class : " + spaceObject.GetClass() + " for space object : " + spaceObject.gameObject.name);
             }
         }
         else if (spaceObject.GetSize() == "Large")
         {
             m_EnemyLargeShips.Add(spaceObject);
             m_EnemyLargeShips.Add(spaceObject);
             if (spaceObject.GetClass() == "AssaultFregate")
             {
                 m_EnemyAssaultFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "ArtilleryFregate")
             {
                 m_EnemyArtilleryFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "SupportFregate")
             {
                 m_EnemySupportFregate.Add(spaceObject);
             }
             else if (spaceObject.GetClass() == "AntiFighterFregate")
             {
                 m_EnemyAntiFighterFregate.Add(spaceObject);
             }
             else
             {
                 Debug.LogError("invalid class : " + spaceObject.GetClass() + " for space object : " + spaceObject.gameObject.name);
             }
         }
         else
         {
             Debug.LogError("invalid size : " + spaceObject.GetSize() + " for space object : " + spaceObject.gameObject.name);
         }
     }
     else
     {
         Debug.LogError("invalid faction : " + spaceObject.GetFaction() + " for space object : " + spaceObject.gameObject.name);
     }
 }