Esempio n. 1
0
 // Update is called once per frame
 public void Update()
 {
     if (findingPlacement)
     {
         if (CanPlaceBuilding())
         {
             tempBuilding.SetTransparentMaterial(allowedMaterial, false);
         }
         else
         {
             tempBuilding.SetTransparentMaterial(notAllowedMaterial, false);
         }
     }
 }
Esempio n. 2
0
    public void CreateBuilding(string buildingName, Vector2d buildPoint, RTSAgent creator, Rect playingArea)
    {
        GameObject newBuilding = Instantiate(ResourceManager.GetAgentTemplate(buildingName).gameObject);

        tempBuilding = newBuilding.GetComponent <RTSAgent>();
        if (tempBuilding.MyAgentType == AgentType.Building)
        {
            tempBuilding.name = buildingName;
            tempBuilding.gameObject.transform.position = buildPoint.ToVector3();
            tempCreator      = creator;
            findingPlacement = true;
            tempBuilding.SetTransparentMaterial(notAllowedMaterial, true);
        }
        else
        {
            Destroy(newBuilding);
        }
    }
Esempio n. 3
0
    private void LoadRTSAgents(JsonTextReader reader)
    {
        if (reader == null)
        {
            return;
        }
        RTSAgents agents = GetComponentInChildren <RTSAgents>();
        string    currValue = "", type = "";

        while (reader.Read())
        {
            if (reader.Value != null)
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    currValue = (string)reader.Value;
                }
                else if (currValue == "Type")
                {
                    type = (string)reader.Value;
                    // need to create unit via commander controller...
                    GameObject newObject = Instantiate(ResourceManager.GetAgentTemplate(type).gameObject);
                    RTSAgent   agent     = newObject.GetComponent <RTSAgent>();
                    agent.name = agent.name.Replace("(Clone)", "").Trim();
                    agent.LoadDetails(reader);
                    agent.transform.parent = agents.transform;
                    agent.SetCommander();
                    agent.SetTeamColor();

                    if (agent.GetAbility <Structure>().UnderConstruction())
                    {
                        agent.SetTransparentMaterial(CachedBuilderManager.allowedMaterial, true);
                    }
                }
            }
            else if (reader.TokenType == JsonToken.EndArray)
            {
                return;
            }
        }
    }