Beispiel #1
0
        /// <summary>
        /// Gets an BaseInteractiveObject's reference id by name.  If the target is "none" or does not exist, -1 is returned.If the target is "self" or "me", -2;
        /// </summary>
        /// <param name="name">the BaseInteractiveObject's name</param>
        /// <returns>int</returns>
        public int GetTargetByNameTarget(string name)
        {
            int ioid = -1;

            if (name != null)
            {
                if (string.Equals(name, "self", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(name, "me", StringComparison.OrdinalIgnoreCase))
                {
                    ioid = -2;
                }
                else if (string.Equals(name, "player", StringComparison.OrdinalIgnoreCase))
                {
                    ioid = ProjectConstants.Instance.GetPlayer();
                }
                else
                {
                    BaseInteractiveObject[] ios = this.GetIOs();
                    for (int i = ios.Length - 1; i >= 0; i--)
                    {
                        BaseInteractiveObject io = ios[i];
                        if (io.HasIOFlag(IoGlobals.IO_03_NPC))
                        {
                            if (string.Equals(name, io.NpcData.Name, StringComparison.OrdinalIgnoreCase))
                            {
                                ioid = io.RefId;
                                break;
                            }
                        }
                        else if (io.HasIOFlag(IoGlobals.IO_02_ITEM))
                        {
                            if (string.Equals(name, io.ItemData.ItemName, StringComparison.OrdinalIgnoreCase))
                            {
                                ioid = io.RefId;
                                break;
                            }
                        }
                        io = null;
                    }
                    ios = null;
                }
            }
            return(ioid);
        }
Beispiel #2
0
        public int GetInterNum(BaseInteractiveObject io)
        {
            int num = -1;

            if (io != null)
            {
                BaseInteractiveObject[] objs = GetIOs();
                for (int i = objs.Length - 1; i >= 0; i--)
                {
                    if (objs[i].Equals(io))
                    {
                        num = i;
                        break;
                    }
                }
                objs = null;
            }
            return(num);
        }
Beispiel #3
0
        /// <summary>
        /// Adds an interactive object to the scene.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="flags"></param>
        /// <returns></returns>
        public BaseInteractiveObject AddItem(string item, long flags)
        {
            BaseInteractiveObject io = null;

            // TODO - fix this
            // BaseInteractiveObject io = WebServiceClient.Instance.GetItemByName(item);
            if (io != null)
            {
                // add additional flags, such as GOLD or MOVABLE
                if ((flags & IoGlobals.NO_ON_LOAD) != IoGlobals.NO_ON_LOAD)
                {
                    Script.Instance.SendIOScriptEvent(io, ScriptConsts.SM_041_LOAD, null, "");
                }
                // TODO - remove spellcasting data
                // io->spellcast_data.castingspell = -1;
                // TODO -set texture and position
            }
            return(io);
        }
 void Awake()
 {
     _baseInteractiveObject = GetComponent <BaseInteractiveObject>();
     if (GetComponent <Rigidbody>())
     {
         _rb    = GetComponent <Rigidbody>();
         Object = transform;
     }
     else if (GetComponentInChildren <Rigidbody>())
     {
         _rb    = GetComponentInChildren <Rigidbody>();
         Object = transform.GetChild(0);
     }
     else
     {
         Debug.LogError("No Rigidbody on Object", this);
     }
     _rb.detectCollisions = true;
 }
Beispiel #5
0
        /**
         * Determines if the {@link Interactive} has a specific interactive object.
         * @param io the BaseInteractiveObject
         * @return true if that interactive object has been stored already; false
         *         otherwise
         */
        public bool HasIO(BaseInteractiveObject io)
        {
            bool has = false;

            if (io != null)
            {
                BaseInteractiveObject[] objs = GetIOs();
                for (int i = objs.Length - 1; i >= 0; i--)
                {
                    if (objs[i] != null &&
                        io.RefId == objs[i].RefId &&
                        io.Equals(objs[i]))
                    {
                        has = true;
                        break;
                    }
                }
                objs = null;
            }
            return(has);
        }
Beispiel #6
0
        /**
         * Determines if two separate IOs represent the same object. Two objects are
         * considered the same if they are both non-unique items that have the same
         * name. PCs and NPCs will always return <tt>false</tt> when compared.
         * @param io0 the first BaseInteractiveObject
         * @param io1 the second BaseInteractiveObject
         * @return <tt>true</tt> if the IOs represent the same object;
         *         <tt>false</tt> otherwise
         */
        public bool IsSameObject(BaseInteractiveObject io0, BaseInteractiveObject io1)
        {
            bool same = false;

            if (io0 != null &&
                io1 != null)
            {
                if (!io0.HasIOFlag(IoGlobals.IO_13_UNIQUE) &&
                    !io1.HasIOFlag(IoGlobals.IO_13_UNIQUE))
                {
                    if (io0.HasIOFlag(IoGlobals.IO_02_ITEM) &&
                        io1.HasIOFlag(IoGlobals.IO_02_ITEM) &&
                        io0.Overscript == null &&
                        io1.Overscript == null &&
                        string.Equals(io0.ItemData.ItemName, io1.ItemData.ItemName, StringComparison.OrdinalIgnoreCase))
                    {
                        same = true;
                    }
                }
            }
            return(same);
        }
Beispiel #7
0
        /// <summary>
        /// Gets a <see cref="BaseInteractiveObject"/> by its reference id.
        /// </summary>
        /// <param name="id">the reference id</param>
        /// <returns><see cref="BaseInteractiveObject"/></returns>
        public BaseInteractiveObject GetIO(int id)
        {
            BaseInteractiveObject io = null;

            if (HasIO(id))
            {
                BaseInteractiveObject[] objs = GetIOs();
                for (int i = objs.Length - 1; i >= 0; i--)
                {
                    if (objs[i] != null &&
                        objs[i].RefId == id)
                    {
                        io = objs[i];
                        break;
                    }
                }
                objs = null;
            }
            else
            {
                throw new RPGException(ErrorMessage.INTERNAL_BAD_ARGUMENT, "BaseInteractiveObject does not exist");
            }
            return(io);
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new interactive object.
 /// </summary>
 protected virtual void NewIO(BaseInteractiveObject io)
 {
     throw new NotImplementedException();
 }
Beispiel #9
0
 public virtual float ComputeDamages(BaseInteractiveObject srcIo, BaseInteractiveObject wpnIo, BaseInteractiveObject targetIo, long flags)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public virtual void ForceIOLeaveZone(BaseInteractiveObject io, long flags)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
        public void DestroyIO(BaseInteractiveObject io)
        {
            if (io != null &&
                io.Show != IoGlobals.SHOW_FLAG_DESTROYED)
            {
                ForceIOLeaveZone(io, 0);
                // if interactive object was being dragged
                // if (DRAGINTER == ioo) {
                // set drag object to null
                // Set_DragInter(NULL);
                // }

                // if interactive object was being hovered by mouse
                // if (FlyingOverIO == ioo) {
                // set hovered object to null
                // FlyingOverIO = NULL;
                // }

                // if interactive object was being combined
                // if (COMBINE == ioo) {
                // set combined object to null
                // COMBINE = NULL;
                // }
                if (io.HasIOFlag(IoGlobals.IO_02_ITEM) &&
                    io.ItemData.Count > 1)
                {
                    io.ItemData.AdjustCount(-1);
                }
                else
                {
                    // Kill all spells
                    int numm = GetInterNum(io);

                    if (HasIO(numm))
                    {
                        // kill all spells from caster
                        // ARX_SPELLS_FizzleAllSpellsFromCaster(numm);
                    }

                    // Need To Kill timers
                    Script.Instance.TimerClearByIO(io);
                    io.Show = IoGlobals.SHOW_FLAG_DESTROYED;
                    io.RemoveGameFlag(IoGlobals.GFLAG_ISINTREATZONE);

                    if (!FAST_RELEASE)
                    {
                        RemoveFromAllInventories(io);
                    }
                    // unlink from any other IOs
                    // if (ioo->obj) {
                    // EERIE_3DOBJ * eobj = ioo->obj;
                    // while (eobj->nblinked) {
                    // long k = 0;
                    // if ((eobj->linked[k].lgroup != -1)
                    // && eobj->linked[k].obj) {
                    // INTERACTIVE_OBJ * iooo =
                    // (INTERACTIVE_OBJ *)eobj->linked[k].io;

                    // if ((iooo) && ValidIOAddress(iooo)) {
                    // EERIE_LINKEDOBJ_UnLinkObjectFromObject(
                    // ioo->obj, iooo->obj);
                    // ARX_INTERACTIVE_DestroyIO(iooo);
                    // }
                    // }
                    // }
                    // }

                    DestroyDynamicInfo(io);

                    if (io.ScriptLoaded)
                    {
                        int num = GetInterNum(io);
                        ReleaseIO(io);

                        if (HasIO(num))
                        {
                            GetIOs()[num] = null;
                        }
                    }
                }
                print("making call to destroy io now");
                // detach the IO from its parent
                io.transform.parent = null;
                SpriteRenderer sr = io.GetComponent <SpriteRenderer>();
                if (sr != null)
                {
                    sr.sprite = null;
                    Destroy(sr);
                }
                BoxCollider2D bc = io.GetComponent <BoxCollider2D>();
                if (bc != null)
                {
                    Destroy(bc);
                }
                Rigidbody2D rb = io.GetComponent <Rigidbody2D>();
                if (rb != null)
                {
                    Destroy(rb);
                }
                io.transform.position = new Vector3(-1, -1, 0);
                Destroy(io);
            }
        }
 void Start()
 {
     interactive = GetComponent <BaseInteractiveObject>();
 }
 void Awake()
 {
     _baseInteractiveObject = GetComponent <BaseInteractiveObject>();
     rends      = GetComponents <Renderer>();
     childRends = GetComponentsInChildren <Renderer>();
 }
Beispiel #14
0
 public virtual bool StrikeCheck(BaseInteractiveObject srcIo, BaseInteractiveObject wpnIo, long flags, int targ)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public virtual void DamageFix(BaseInteractiveObject io, float dmg, long source, long flags)
 {
     throw new NotImplementedException();
 }
Beispiel #16
0
 public void TeleportBehindTarget(BaseInteractiveObject io)
 {
     // TODO Auto-generated method stub
 }
Beispiel #17
0
 public abstract int AddSpeech(BaseInteractiveObject io, int mood, string speech, long voixoff);
Beispiel #18
0
 private void OnEnable()
 {
     _interactiveObject = (BaseInteractiveObject)target;
     SpriteCollection   = (SpriteCollection)Resources.Load("Cursors");
     _interactiveObject.InteractComponentsList = (InteractComponents)Resources.Load("InteractComponents");
 }