示例#1
0
 public Thief(IWeaponItem weapon, Point initialPosition, IEnvironmentContainer environmentContainer)
     : base(weapon, initialPosition, environmentContainer)
 {
     Stats              = new DefaultStats(Common.Settings.ActorSettings.DefaultSize, 30, 9, Common.Settings.ActorSettings.ThiefStepLength);
     _animation         = new ThiefAnimation();
     _collisionResolver = new DefaultCollisionResolver(this);
     _isInteractive     = true;
 }
示例#2
0
 public CharacterStats(DefaultStats defaultStats)
 {
     _defaultStats = defaultStats;
     Life          = _defaultStats.Life;
     Attack        = _defaultStats.Attack;
     Defense       = _defaultStats.Defense;
     Experience    = _defaultStats.Experience;
     Speed         = _defaultStats.Speed;
 }
示例#3
0
        //Constructor:
        public ObjectState(GameObject obj)
        {
            properties = DefaultStats.DeepClone(obj.GetComponent <ObjectScript>().properties);

            name     = obj.GetComponent <SpriteRenderer>().sprite.name;
            position = new Vector2(obj.transform.position.x, obj.transform.position.y);
            rotation = obj.transform.rotation;
            scale    = obj.transform.localScale;
            mass     = obj.GetComponent <Rigidbody2D>().mass;
        }
示例#4
0
    /// <summary>
    /// Erstellt neue Einheit aus der Gleichung heraus
    /// </summary>
    public void CreateUnit()
    {
        string term = "";
        string abbr;

        foreach (GameObject unit in divident)
        {
            abbr = "";
            FormulaList.nameToAbbr.TryGetValue(unit.GetComponent <SpriteRenderer>().sprite.name, out abbr);
            term += abbr;
        }
        term += "/(";
        foreach (GameObject unit in divisor)
        {
            abbr = "";
            FormulaList.nameToAbbr.TryGetValue(unit.GetComponent <SpriteRenderer>().sprite.name, out abbr);
            term += abbr;
        }
        term += ")";
        Debug.Log(term);
        string sDivident = "";
        string sDivisor  = "";
        string unitName  = "";

        DoConvertion(term, out sDivident, out sDivisor);
        if (sDivisor.Length > 0 || !FormulaList.abbrToName.TryGetValue(sDivident, out unitName))
        {
            StartCoroutine(WrongAnimation());
        }
        else
        {
            //Spawne neue Einheit:
            wrong.SetActive(false);
            block = true;

            //langsam:
            DefaultStats.SetDefaultCharValueByName(unitName);
            foreach (GameObject unit in divident)
            {
                DefaultStats.SetDefaultCharValueByName(unit.name);
            }
            foreach (GameObject unit in divisor)
            {
                DefaultStats.SetDefaultCharValueByName(unit.name);
            }

            //Debug.Log(PlayerScript.allies[0].GetComponent<GroupScript>().properties.size);//Es muss dafür noch mindestens eine Einheit außerhalb der Gleichung sein

            StartCoroutine(FadeTermUnits());
            SpawnUnit(unitName, wrong.transform.localPosition);
        }
    }
示例#5
0
    private GameObject SpawnUnit(string unitName, Vector2 position, bool moveAnim = true)
    {
        GameObject obj = Resources.Load <GameObject>("Units/" + unitName);

        obj = Instantiate(obj, transform);

        obj.name = obj.GetComponent <SpriteRenderer>().sprite.name;
        obj.transform.localPosition = position;
        obj.transform.parent        = null;
        obj.transform.localScale    = new Vector3(0.1f, 0.1f);
        obj.GetComponent <CapsuleCollider2D>().enabled = false;
        obj.transform.GetChild(2).gameObject.SetActive(false);
        obj.GetComponent <Rigidbody2D>().bodyType   = RigidbodyType2D.Kinematic;
        obj.GetComponent <SpriteRenderer>().color   = new Color(1, 1, 1, 0);
        obj.GetComponent <GroupScript>().properties = DefaultStats.DeepClone(PlayerScript.allies.Count > 0 ? PlayerScript.allies[0].GetComponent <GroupScript>().properties : DefaultStats.defaultChar);
        StartCoroutine(SpawnAnimation(obj, moveAnim));
        return(obj);
    }
示例#6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Falls Verbündet, dann gebe das Signal zu folgen
        GroupScript groupScript = other.GetComponent <GroupScript>();

        //wenn der Char der Gruppe schon angehört, dann ignorieren:
        if (groupScript.inGroup)
        {
            return;
        }

        //weiße den Char, dem gefolgt werden soll, zu:
        groupScript.groupNumber = PlayerScript.allies.Count;
        if (PlayerScript.allies.Count == 0)
        {
            groupScript.charToFollow = transform.parent.gameObject;
        }
        else
        {
            groupScript.charToFollow = PlayerScript.allies[PlayerScript.allies.Count - 1];
        }

        other.name = other.GetComponent <SpriteRenderer>().sprite.name;
        PlayerScript.allies.Add(other.gameObject);
        PlayerScript.alliesNames.Add(other.name);
        PlayerScript.collectedAlliesCurrent.Add(other.name);
        PlayerScript.spawnPositions.Add(other.transform.position);
        other.GetComponent <GroupScript>().properties = PlayerScript.allies[0].GetComponent <GroupScript>().properties;//shallow, mehr aber auch nicht vonöten

        //Überschreibe wert mit defaultwert:
        DefaultStats.SetDefaultCharValueByName(other.name);

        //folge dem Char:
        groupScript.inGroup = true;
        groupScript.bottom  = true;
        return;
    }