public override void applyFailure(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets)
        {
            // TODO: well - just remove 1/2 of the mana costs? if critical, remove full mana costs
            int minutes = 0;

            int MaPcost = (luck == ELuck.slipup) ? minutes * 3 : (minutes * 3) / 2;
            user.drainMana(MaPcost);
        }
Beispiel #2
0
        public override bool use(string[] args, EntityController pc)
        {
            string arg_line = "";
            foreach (string s in args)
                arg_line += s + ",";

            MonoBehaviour.print("Test command executed. args: " + arg_line);
            return true;
        }
Beispiel #3
0
        public override int getTestModifier(int version, EntityController user, List<PraeObject> targets)
        {
            if (targets == null || targets.Count() == 0)
                return 0;

            float dist = Vector3.Distance(user.position, targets.First().position);
            if (dist > user.praeObject.meleeRange)
                throw new GameLogicException("Melee attacks shall only be usable when user within melee range!");
            return 0;
        }
Beispiel #4
0
        /**
         * @ec: controller which uses this manager
         */
        public AbilityManager(EntityController ec)
        {
            if (ec == null)
                throw new System.NullReferenceException("AbilityManager cannot be instantiated without an appropriate entitycontroller!");
            entityC = ec;

            abilities = new Dictionary<EAbilities, AbstractAbility>();
            abilities.Add(EAbilities.null_, new NullAbility());
            abilities.Add(EAbilities.test, new AbilityTest());
            abilities.Add(EAbilities.Astrahlbelebung, new AbilityAstralbelebung());
            // TODO: add abilities here
        }
        public override bool use(string[] args, EntityController pc)
        {
            string abiName = args[0];
            foreach (EAbilities A in Enum.GetValues(typeof(EAbilities)))
            {
                if (abiName.Equals(A.ToString())) // find the ability to execute
                {
                    pc.executeAbilityWith(A); // let the player controller handle the rest
                    return true;
                }
            }

            throw new ArgumentException("Could not find ability with name " + abiName);
        }
Beispiel #6
0
        public void parseCommandLine(String cmdline, EntityController pc)
        {
            if (cmdline == null)
                throw new ArgumentNullException("parseCommandLine: given cmdline was empty!");

            String[] input = cmdline.Split(' '); // seperate by empty spaces
            if (input.Length > 0)
            {
                AbstractCommand cmd = null;
                commandList.TryGetValue(input[0], out cmd);
                if (cmd == null)
                    throw new CommandNotFoundException(input[0]);
                else
                    cmd.use(input.Skip(1).ToArray(), pc);
            }
        }
        public override void applySuccess(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets)
        {
            int IN = ((rp+1)/2 == rp/2) ? rp / 2 : (rp/2) + 1; // if rp is uneven, add +1 to rp/2
            int LO = rp / 2;
            Debug.Assert(IN + LO == rp, PRE + "calculation error: IN+LO == rp invalidated!");

            // TODO: animate object with these stats
            Debug.Assert(version == VER_SINGLE_TARGET, "verison bug?");
            int minutes = UnityEngine.Random.Range(1,10) * Constants.gameTimeMultiplier;
            DateTime endtime = DateTime.Now.AddMinutes(minutes);
            InteractionComponent c = targets[0].AddInteractionComponent();

            Constants.gameLogic.AddTimedInteraction(c, endtime);
            Debug.Log("Astrahlbelebung. Object will come to life for " + minutes + "minutes: " + targets[0]);

            // drain costs from user
            int MaPcost = minutes * 3;
            user.drainMana(MaPcost);
        }
        /**
         * We need:
         * - at least 1 target
         * - target[s] must be liveless
         */
        public override bool canUse(int version, EntityController user, List<PraeObject> targets)
        {
            if (version == VER_SINGLE_TARGET)
                if (targets.Count == 1)
                    if (targets[0].inanimate)
                        if (targets[0].weight <= fw)
                            if (!targets[0].HasInteraction())
                                return true; // all conditions met
                            else
                                Debug.Log("Object already has interaction!");
                        else
                            Debug.Log(PRE + "Object is to heavy");
                    else
                        Debug.Log(PRE + "Object is alive!");
                else
                    Debug.Log(PRE + "Zero or more than 1 target given. Exactly 1 expected!");
            else
                Debug.LogError(PRE + "ERROR: Version " + version + " not existing!");

            return false;
        }
 /**
  * test, whether or not this ability can be used by 'user' on 'targets'
  * @user: the one using this ability
  * @targets: any kind of object/entity that is effected by this ability
  */
 public abstract bool canUse(int version, EntityController user, List<PraeObject> targets);
Beispiel #10
0
 public override bool canUse(int version, EntityController user, List<PraeObject> targets)
 {
     // no self cast
     return targets == null || !targets.Contains(user.praeObject);
 }
Beispiel #11
0
 public override List<PraeObject> getTargets(int version, EntityController user)
 {
     return null;
 }
Beispiel #12
0
 public override void applyFailure(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets)
 {
     UnityEngine.MonoBehaviour.print("Test ability finally failed!");
 }
Beispiel #13
0
 public override void applySuccess(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets)
 {
     UnityEngine.MonoBehaviour.print("Test ability successfully used!");
 }
Beispiel #14
0
        // load character data
        public bool LoadEntityData(EntityController ec, string path)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(EntitySaveData));
                FileStream stream = new FileStream(Application.dataPath + path, FileMode.Open);
                EntitySaveData entSave = serializer.Deserialize(stream) as EntitySaveData;
                stream.Close();

                if (entSave == null)
                    throw new FileNotFoundException("entSave was not loaded. SaveFile not present at: " + path);

                ec.abiList = entSave.abiList;
                ec.attrGrpList = entSave.attrGrpList;
                ec.attrOtherList = entSave.attrOtherList;
                ec.inventory = entSave.inventory;
                ec.interComp.conAssets = entSave.conversationAssets;
                // TODO: read entData here

                if (ReferenceEquals(ec, Constants.gameLogic.pc))
                    Debug.Log("Main Character loaded.");
                else
                    Debug.Log("Entity loaded.");

                return true;
            }
            catch (FileNotFoundException e)
            {
                Debug.LogError(e.Message);
                return false;
            }
        }
Beispiel #15
0
 /**
  * TODO: HEADER NEEDS SOME INPUT
  * the returned value will be added to the ability level pool (fw + aw + modifier)
  * @version: most abilities have different usage modes. Can be used as bitflag
  * @user: the one using this ability
  * @targets: any kind of object/entity that is effected by this ability
  */
 public abstract int getTestModifier(int version, EntityController user, List<PraeObject> targets);
Beispiel #16
0
        public void Start()
        {
            _mainChar = GameObject.FindGameObjectWithTag("MainCharacter");
            _pc = _mainChar.GetComponent<EntityController>();

            if (!_mainChar || !_pc)
                //TODO: LOAD CHARACTER FORM PRESET!
                throw new NullReferenceException("GameManager could not find mainCharacter or his attached controller!!!!");
        }
Beispiel #17
0
        public void SaveEntityData(EntityController ec, string path)
        {
            EntitySaveData entData = new EntitySaveData();
            entData.abiList = ec.abiList;
            entData.attrGrpList = ec.attrGrpList;
            entData.attrOtherList = ec.attrOtherList;
            entData.inventory = ec.inventory;
            entData.conversationAssets = ec.interComp.conAssets;
            // TODO: fill entData here

            XmlSerializer serializer = new XmlSerializer(typeof(EntitySaveData));
            FileStream stream = new FileStream(Application.dataPath + path, FileMode.Create);
            serializer.Serialize(stream, entData);
            stream.Close();

            if (ReferenceEquals(ec, Constants.gameLogic.pc))
                Debug.Log("Main Character saved.");
            else
                Debug.Log("Entity saved.");
        }
 public override bool use(string[] args, EntityController pc)
 {
     Constants.chatManager.addLine( (args == null) ? null : String.Join(" ", args));
     return true;
 }
 public override int getTestModifier(int version, EntityController user, List<PraeObject> targets)
 {
     if (version == VER_SINGLE_TARGET)
         return 0;
     else
         throw new NotImplementedException();
 }
Beispiel #20
0
        /**
         * DEBUG VERSION
         * Func: Basic dice roll test function for the use of abilities in the game
         * @version: changes specifics of 'ability'
         * @minRP: minimum Restpunkte required for a successful test
         * @ability: the one that will be executed
         * @user: entity using the ability
         * @targets: potential targets for the ability (if necessary)
         */
        public void testInstant(int version, int minRP, AbstractAbility ability, EntityController user, List<PraeObject> targets)
        {
            if (ability.canUse(version, user, targets))
            {
                int c = ability.getTestModifier(version, user, targets);            // Erschwernis/Erleichterung
                Debug.Log(charInfo);
                int aw = charInfo.getAttributeValue(ability.attributeGroup);        // Value of assigned attribute
                int fw = ability.fw;                                                // Fertigkeitswert of ability
                ELuck luck = ELuck.normal;

                int diceroll = UnityEngine.Random.Range(1, 21); // [inclusive, exclusive]
                int rp = fw + aw - c - diceroll;

                if (diceroll == 1)
                {
                    // test for luck, "Glücksgriff"
                    int second_roll = UnityEngine.Random.Range(1, 21);
                    if (second_roll <= aw)
                    {
                        rp += 20 + second_roll - aw; // normal rp + second_roll rp + 20
                        luck = ELuck.luck;
                    }
                }
                else if (diceroll == 20)
                {
                    // test for slipup "Patzer"
                    int reroll = UnityEngine.Random.Range(1, 21);
                    if (reroll > aw + Math.Max(0, rp)) // if aw + fp > 20, we add positive rp to the pool
                        luck = ELuck.slipup;
                }

                Debug.Log("Ability: " + ability + "| Dice: " + diceroll + " rp: " + rp + " fw: " + fw + " aw: " + aw + " luck: " + luck);
                Constants.chatManager.addLine("Ability: " + ability);
                Constants.chatManager.addLine("Dice: " + diceroll + " rp: " + rp + " fw: " + fw + " aw: " + aw + " luck: " + luck);

                if (rp >= minRP)
                {
                    Constants.chatManager.addLine("Success!");
                    ability.applySuccess(version, rp, luck, user, targets);
                }
                else
                {
                    Constants.chatManager.addLine("Failed!");
                    ability.applyFailure(version, rp, luck, user, targets);
                }
            }
            else
            {
                Debug.Log("Cannot use ability " + ability.ToString() + ".");
            }
        }
Beispiel #21
0
 /**
  * Func: Basic dice roll test function for the use of abilities in the game
  * Func: this version should be called by entity controller when using interfaces for targets
  * Func: uses GameManager to determine minimal required RP
  * @version: changes specifics of 'ability'
  * @ability: the one that will be executed
  * @user: entity using the ability
  * @targets: potential targets for the ability (if necessary)
  */
 public void testInstant(int version, AbstractAbility ability, EntityController user, List<PraeObject> targets)
 {
     int minRP = 0; //TODO: the GameManager should somehow determine this value
     testInstant(version, minRP, ability, user, targets);
 }
Beispiel #22
0
 public TestManager(EntityController ec)
 {
     entityC = ec;
     charInfo = entityC.entityInfo;
 }
Beispiel #23
0
 public override void makeVisuals(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets)
 {
     throw new NotImplementedException();
 }
Beispiel #24
0
 /**
  * gets called from the TestManager after rolling some dice
  * rp are the remaining points of the test
  * @version: most abilities have different usage modes. Can be used as bitflag
  * @rp: the absolute difference between the required and the roled test value
  * @luck:    normal, slipup or luck
  * @user: the one using this ability
  * @targets: any kind of object/entity that is effected by this ability
  */
 public abstract void applySuccess(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets);
Beispiel #25
0
 /*
  * use command with the given arguments
  * returns TRUE, if the command was useable
  * returns FALSE, if any issue occured
  */
 public abstract bool use(string[] args, EntityController pc);
        public override List<PraeObject> getTargets(int version, EntityController user)
        {
            if (version == VER_SINGLE_TARGET)
            {
                List<PraeObject> targets = null;
                RaycastHit hitinfo;
                Debug.DrawLine(user.transform.position, user.transform.position + user.lookDir * maxRange, Color.green, 10f);
                if (Physics.Raycast(user.transform.position, user.lookDir, out hitinfo, 30f))
                {
                    PraeObject obj = hitinfo.transform.gameObject.GetComponent<PraeObject>();
                    if (obj)
                    {
                        targets = new List<PraeObject>(2);
                        targets.Add(obj);
                        Debug.Log("Found target: " + obj);
                    }
                    else
                    {
                        Debug.Log("Could not find targets in range.");
                    }
                }

                return targets;
            }
            else
                throw new NotImplementedException();
        }
Beispiel #27
0
 public void SaveEntityData(EntityController ec, int charid)
 {
     SaveEntityData(ec, charXMLPrefix + charid + ".xml");
 }
Beispiel #28
0
 /**
  * func: return a list of targets, if possible
  * func: use 'canUse' of targets before using the ability
  * @version: ability specific modifier
  * @user:    the one using the ability
  */
 public abstract List<PraeObject> getTargets(int version, EntityController user);
Beispiel #29
0
        void Start()
        {
            playerC = GameObject.FindGameObjectWithTag("MainCharacter").GetComponent<EntityController>();
            foreach (var g in GameObject.FindGameObjectsWithTag("MainCharacter"))
            {
                print(g.name);
            }
            cmdParser = new CommandParser(playerC);
            contentText.text = chatline;

            if (maxLinesToShow > 0)
            {
                fromLineIndex = 0;
                toLineIndex = maxLinesToShow-1;

                for (int i = 0; i < maxLinesToShow; i++)
                    lines.Add("");
            }
        }
Beispiel #30
0
 /**
  * func:     handles all the visual effects in the game
  * @version: most abilities have different usage modes. Can be used as bitflag
  * @rp:      the absolute difference between the required and the roled test value
  * @luck:    normal, slipup or luck
  * @user:    the one using this ability
  * @targets: any kind of object/entity that is effected by this ability
  */
 public abstract void makeVisuals(int version, int rp, ELuck luck, EntityController user, List<PraeObject> targets);