Exemplo n.º 1
0
    public InteractuableResult Interacted(RaycastHit hit = new RaycastHit())
    {
        InteractuableResult ret = InteractuableResult.IGNORES;

        if (aad.getInfluenceArea() != null)
        {
        }

        switch (aad.getBehaviour())
        {
        case Item.BehaviourType.FIRST_ACTION:
            foreach (Action a in aad.getActions())
            {
                if (ConditionChecker.check(a.getConditions()))
                {
                    Game.Instance.Execute(new EffectHolder(a.getEffects()));
                    break;
                }
            }
            ret = InteractuableResult.DOES_SOMETHING;
            break;

        case Item.BehaviourType.NORMAL:
            List <Action> available = new List <Action> ();
            foreach (Action a in aad.getActions())
            {
                if (ConditionChecker.check(a.getConditions()))
                {
                    bool addaction = true;
                    foreach (Action a2 in available)
                    {
                        if ((a.getType() == Action.CUSTOM || a.getType() == Action.CUSTOM_INTERACT) && (a2.getType() == Action.CUSTOM || a2.getType() == Action.CUSTOM_INTERACT))
                        {
                            if (((CustomAction)a).getName() == ((CustomAction)a2).getName())
                            {
                                addaction = false;
                                break;
                            }
                        }
                        else if (a.getType() == a2.getType())
                        {
                            addaction = false;
                            break;
                        }
                    }

                    if (addaction)
                    {
                        available.Add(a);
                    }
                }
            }

            //We check if it's an examine action, otherwise we create one and add it
            bool   addexamine = true;
            string desc       = aad.getDescription(0).getDetailedDescription();
            if (desc != "")
            {
                foreach (Action a in available)
                {
                    if (a.getType() == Action.EXAMINE)
                    {
                        addexamine = false;
                        break;
                    }
                }

                if (addexamine)
                {
                    Action  ex    = new Action(Action.EXAMINE);
                    Effects exeff = new Effects();
                    exeff.add(new SpeakPlayerEffect(desc));
                    ex.setEffects(exeff);
                    available.Add(ex);
                }
            }

            if (available.Count > 0)
            {
                Game.Instance.showActions(available, Input.mousePosition);
                ret = InteractuableResult.DOES_SOMETHING;
            }
            break;

        case Item.BehaviourType.ATREZZO:
        default:
            ret = InteractuableResult.IGNORES;
            break;
        }

        return(ret);
    }