示例#1
0
    // Use this for initialization
    void Start()
    {
        this.logger.Log("configuring global script class");

        MapElementHighlight.enabled = false;

        cameraBehavior   = mainCamera.GetComponent <CameraBehavior>();
        listOfMapObjects = new List <Assets.Scripts.Map.MapObject>();

        var filter = gameObject.AddComponent <MeshFilter>();

        gameObject.AddComponent <MeshRenderer>();

        var mapLoader = new MapLoader();

        this.gameMap = mapLoader.LoadMapFromJson(Assets.Scripts.Map.GlobalMapConfig.JsonMapPath);

        //set prefabs for objectRenderer
        objectRenderer.setPrefabs(prefab_archer, prefab_swordsman, prefab_mutant, prefab_horseman, prefab_castle);

        var mapRenderer = new MapRenderer(GameMap, prefab_trees, prefab_grass, prefab_water, prefab_sand, listOfMapObjects, objectRenderer);

        mapRenderer.RenderTheMap();
        UserTurn = 0;


        winNotification = (WinNotificationUI)GameObject.Find("WinNotificationPanel").GetComponent(typeof(WinNotificationUI));
    }
示例#2
0
 public void setParameters(Assets.Scripts.Map.Map map, List <Assets.Scripts.Map.MapObject> listOfMapObjects, float scale, float square_xz, float separator, Vector2 mapStart)
 {
     this.map = map;
     this.listOfMapObjects = listOfMapObjects;
     this.separator        = separator;
     this.square_xz        = square_xz;
     this.scale            = scale;
     this.mapStart         = mapStart;
 }
示例#3
0
 public MapRenderer(Assets.Scripts.Map.Map map, Transform prefab_trees,
                    Transform prefab_grass, Transform prefab_water, Transform prefab_sand,
                    List <Assets.Scripts.Map.MapObject> listOfMapObjects, ObjectRenderer objectRenderer)
 {
     this.map = map;
     this.listOfMapObjects = listOfMapObjects;
     this.objectRenderer   = objectRenderer;
     this.prefab_trees     = prefab_trees;
     prefabs = new List <Transform> {
         prefab_grass, prefab_water, prefab_sand
     };
 }
示例#4
0
 public ObjectRenderer(Assets.Scripts.Map.Map map, List <Assets.Scripts.Map.MapObject> listOfMapObjects, float scale, float square_xz, float separator)
 {
     setParameters(map, listOfMapObjects, scale, square_xz, separator, new Vector2(0, 0));
 }
示例#5
0
        public static GameObject Create(Type type,
                                        Vector3 position)
        {
            GameObject itemObj = (GameObject)GameObject.Instantiate(Resources.Load <Object>("Item"),
                                                                    position,
                                                                    Quaternion.identity);
            SpriteRenderer renderer = itemObj.GetComponent <SpriteRenderer>();
            Item           item     = itemObj.GetComponent <Item>();

            renderer.sprite = Resources.Load <Sprite>("Items/" + type);
            GameObject mapObj = GameObject.FindGameObjectWithTag("Map");

            Map.Map map = mapObj.GetComponent <Map.Map>();
            itemObj.transform.SetParent(mapObj.transform);
            itemObj.transform.localScale = new Vector3(0.65f, 0.65f, 1.0f);

            const float DEFAULT_BUFF_TIMEOUT_S = 10.0f;

            switch (type)
            {
            case Type.HealthPack:
                item.RestoreHealth = 100.0f;
                break;

            case Type.Bomb:
                item.RestoreHealth  = -25.0f;
                item.ExplosionForce = 1.0f;
                break;

            case Type.StrengthBonus:
                item.ApplyBuff = new Buff(Statistic.Damage,
                                          Buff.Type.Additive,
                                          10.0f,
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/StrengthBonus");
                break;

            case Type.StrengthDouble:
                item.ApplyBuff = new Buff(Statistic.Damage,
                                          Buff.Type.Multiplicative,
                                          2.0f,
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/StrengthDouble");
                break;

            case Type.StrengthHalf:
                item.ApplyBuff = new Buff(Statistic.Damage,
                                          Buff.Type.Multiplicative,
                                          0.5f,
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/StrengthHalf");
                break;

            case Type.WebSwingRangeBonus:
                item.ApplyBuff = new Buff(Statistic.WebSwingRange,
                                          Buff.Type.Additive,
                                          10.0f,
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/WebSwingRangeBonus");
                break;

            case Type.WebSwingRangeInfinite:
                item.ApplyBuff = new Buff(Statistic.WebSwingRange,
                                          Buff.Type.Additive,
                                          1000000.0f,
                                          // good approximation of infinity
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/WebSwingRangeInfinite");
                break;

            case Type.WebSwingRangeHalf:
                item.ApplyBuff = new Buff(Statistic.WebSwingRange,
                                          Buff.Type.Multiplicative,
                                          0.5f,
                                          DEFAULT_BUFF_TIMEOUT_S,
                                          "Items/WebSwingRangeHalf");
                break;

            case Type.EnableRotation:
                item.ApplyEffect = new EnableRotationEffect(map);
                break;
            }

            return(itemObj);
        }
示例#6
0
 // Use this for initialization
 void Start()
 {
     map = GameObject.FindGameObjectWithTag("Map").GetComponent <Map.Map>();
 }
示例#7
0
 public EnableRotationEffect(Map.Map map)
 {
     this.map = map;
 }
示例#8
0
 // Use this for initialization
 protected void Start()
 {
     lifeBar = transform.FindChild("LifeBar");
     map     = FindObjectOfType <Map.Map>();
     rb      = GetComponent <Rigidbody2D> ();
 }
示例#9
0
 // Use this for initialization
 void Start()
 {
     map           = GameObject.FindGameObjectWithTag("Map").GetComponent <Map.Map>();
     rectTransform = GetComponent <RectTransform>();
 }
示例#10
0
        void OnEnable()
        {
            if (PerPlayerStats == null)
            {
                Reset();
            }

            LabeledStat[] perPlayerStats = new LabeledStat[] {
                new LabeledStat()
                {
                    label  = "TotalDamage",
                    values = new string[] {
                        string.Format("{0:F0}", PerPlayerStats[0].TotalDamageDealt),
                        string.Format("{0:F0}", PerPlayerStats[1].TotalDamageDealt)
                    }
                },
                new LabeledStat()
                {
                    label  = "MaxDamage",
                    values = new string[] {
                        string.Format("{0:F0}", PerPlayerStats[0].MaxDamageDealt),
                        string.Format("{0:F0}", PerPlayerStats[1].MaxDamageDealt)
                    }
                },
                new LabeledStat()
                {
                    label  = "Kills",
                    values = new string[] {
                        PerPlayerStats[0].EnemiesKilled.ToString(),
                        PerPlayerStats[1].EnemiesKilled.ToString()
                    }
                },
                new LabeledStat()
                {
                    label  = "ItemsPickedUp",
                    values = new string[] {
                        PerPlayerStats[0].ItemsPickedUp.ToString(),
                        PerPlayerStats[1].ItemsPickedUp.ToString()
                    }
                },
                new LabeledStat()
                {
                    label  = "LongestShot",
                    values = new string[] {
                        string.Format("{0:F3}", PerPlayerStats[0].LongestShot),
                        string.Format("{0:F3}", PerPlayerStats[1].LongestShot)
                    }
                },
            };

            Transform perPlayerStatsContainer = transform.FindChild("PerPlayerStats");

            foreach (LabeledStat stat in perPlayerStats)
            {
                Transform statContainer = perPlayerStatsContainer.FindChild(stat.label);

                statContainer.FindChild("P1").GetComponent <Text>().text = stat.values[0];
                statContainer.FindChild("P2").GetComponent <Text>().text = stat.values[1];

                // TODO: that cast is soo ugly... but works
                statContainer.FindChild("Star1").gameObject.SetActive(double.Parse(stat.values[0]) > double.Parse(stat.values[1]));
                statContainer.FindChild("Star2").gameObject.SetActive(double.Parse(stat.values[0]) < double.Parse(stat.values[1]));
            }

            Transform generalStatsContainer = transform.FindChild("GeneralStats");

            GameObject mapObj = GameObject.FindGameObjectWithTag("Map");

            if (mapObj)
            {
                Map.Map map = mapObj.GetComponent <Map.Map>();
                generalStatsContainer.FindChild("Level/Value").GetComponent <Text>().text = map.Level.ToString();
            }

            TimeSpan gameplayTime = TimeSpan.FromSeconds(Time.time - LastResetTime);

            generalStatsContainer.FindChild("GameplayTime/Value").GetComponent <Text>().text = gameplayTime.ToGameTimeString();
        }