Esempio n. 1
0
 public void RemoveObject(ObjectBase obj)
 {
     if (obj.isOurForce)
         ourForceList.Remove(obj);
     else
         enemyList.Remove(obj);
 }
Esempio n. 2
0
    private void OnEnable() // 유닛이 켜질떄
    {
        target = null;

        if (parent.GetComponent<Launcher>())
            target = parent.GetComponent<Launcher>().GetLauncherTargets(0);
        else
        {
            if (parent.GetTargets() != null)
                target = parent.GetTargets()[0];
        }

        if (hitMultipleObject)
        {
            StartCoroutine(Penetrate());
            return;
        }

        if (target != null)
        {
            transform.position = new Vector2(parent.transform.position.x + adjustPos.x,
            parent.transform.position.y + adjustPos.y);

            StartCoroutine(ChaseUnit());
        }
        else
        {
            gameObject.SetActive(false);
        }
    }
Esempio n. 3
0
 public void AddObject(ObjectBase obj)
 {
     if (obj.isOurForce)
         ourForceList.Add(obj);
     else
         enemyList.Add(obj);
 }
Esempio n. 4
0
 public void Add(ObjectBase obj)
 {
     if (obj.Motion == Vector2.Zero)
         still.Add(obj);
     else
         moving.Add(obj);
 }
    //Put an item to the BackPack
    public void AddItem(ObjectBase item)
    {
        //Get the name of the item
        string itemName = item.name.Substring(0, item.name.IndexOf('('));

        //If its BackPack counterpart is active, add the item to it
        foreach (BackPackItemType itemType in items)
        {
            if (itemType.ContentName() == itemName)
            {
                itemType.AddItem(item);
                return;
            }
        }

        //If we did not find the counterpart in the active objects, scan the inactive items
        foreach (BackPackItemType itemType in inactiveItems)
        {
            //If we found it, activate it
            if (itemType.ContentName() == itemName)
            {
                StartCoroutine(AddItemType(itemType, item));
                return;
            }
        }
    }
Esempio n. 6
0
    public ObjectBase[] GetTargets(ObjectBase obj, float attackRange, int canHitNum, bool isFindOur = false)
    {
        List<ObjectBase> oppositeList = new List<ObjectBase>();

        if (isFindOur)
            oppositeList = GetOpposite(!obj.isOurForce);
        else
            oppositeList = GetOpposite(obj.isOurForce);

        oppositeList = GetSameLine(oppositeList, obj.line);
        oppositeList = SelectInRange(oppositeList, obj.transform.position.x, attackRange, isFindOur);

        if (oppositeList.Count == 0)    // 없을때는 성공격하거나 null
        {
            if (CanAttackCastle(oppositeList, obj))
                return oppositeList.ToArray();
            return null;
        }

        List<ObjectBase> returnList = new List<ObjectBase>();

        for (int i = 0; i < oppositeList.Count; ++i)
        {
            if (i < canHitNum)
                returnList.Add(oppositeList[i]);
        }
        return returnList.ToArray();
    }
    //Adds an item to the active object list
    public void AddItem(ObjectBase item)
    {
        if (!activeObjects.Contains(item))
            activeObjects.Add(item);

        item.transform.parent = activeContainer;
    }
Esempio n. 8
0
        public override object TryConstruct(ObjectBase objectBase, IEnumerable<object> otherArgs)
        {
            var constructed = base.TryConstruct(null, otherArgs);
            if (constructed != null)
                Setter(constructed, objectBase);

            return constructed;
        }
Esempio n. 9
0
 public Prisoner(ObjectBase baseObj)
     : base(baseObj.Label, true) {
     Id = baseObj.Id;
     Type = baseObj.Type;
     ReparseProperties(baseObj);
     CopyNodes(baseObj);
     Bio = (PrisonerBio)PopNode("Bio");
 }
        //Scales the feedback to zero in time
        public void Disable(float time)
        {
            this.target = null;
            feedback.sortingOrder = 1;

            StopCoroutine("Rescale");
            StartCoroutine(Rescale(feedback.transform, new Vector3(0, 0, 1), time));
        }
Esempio n. 11
0
        public void GetIndexeDoesntExistStrict()
        {
            // arrange
            var subject = new ObjectBase(DxSettings.GlobalSettings, true);

            // act
            // assert
            Assert.Throws(typeof(InvalidMockException), () => subject.GetIndex<object>(new MethodArg[0], false));
        }
Esempio n. 12
0
        public void GetIndexeDoesntExistNonStrict()
        {
            // arrange
            var subject = new ObjectBase(DxSettings.GlobalSettings);

            // act
            // assert
            Assert.AreEqual(null, subject.GetIndex<object>(new MethodArg[0], false));
            Assert.AreEqual(0, subject.GetIndex<int>(new MethodArg[0], false));
        }
Esempio n. 13
0
        public void GetInvalidPropertyType()
        {
            // arrange
            var vaues = new MockBuilder();
            ((dynamic)vaues).abc = new object();
            var subject = new ObjectBase(DxSettings.GlobalSettings, vaues);

            // act
            // assert
            Assert.Throws(typeof(InvalidMockException), () => subject.GetProperty<string>("abc", false));
        }
Esempio n. 14
0
    // 타겟 설정해줌
    public void SetTarget(ObjectBase obj)
    {
        if (obj == null)
        {
            Destroy(gameObject);
            return;
        }

        target = obj;
        Attack();
    }
Esempio n. 15
0
        public void GetInvalidIndexeType()
        {
            var key = new[] { new MethodArg<string>("asdsadas", string.Empty) };

            // arrange
            var values = new MockBuilder();
            ((dynamic)values)[key[0].Arg] = new object();
            var subject = new ObjectBase(DxSettings.GlobalSettings, values);

            // act
            // assert
            Assert.Throws(typeof(InvalidMockException), () => subject.GetIndex<string>(key, false));
        }
    public float width; //The width of the BackPack in units (100 pixel = 1 unit)

    #endregion Fields

    #region Methods

    //Adds a prefab clone to the item, and updates counter
    public void AddItem(ObjectBase item)
    {
        placedContent.Remove(item);
        content.Add(item);

        item.transform.eulerAngles = Vector3.zero;
        item.gameObject.SetActive(false);

        if (count == 1)
            counter.gameObject.SetActive(true);

        count++;

        if (count > 1)
            counter.sprite = BackPackNumbers[count - 2];
    }
Esempio n. 17
0
    private IEnumerator HealProcess(ObjectBase healTarget)
    {
        healEffect.SetActive(true);
        while (!healTarget.isDestroyed
            && Mathf.Abs(healTarget.transform.position.x - transform.position.x) <= attackRange * BattleManager.tileSize
            && healTarget.GetHP() != healTarget.maxHP)
        {
            isHealing = true;
            yield return new WaitForSeconds(1f);

            healTarget.SetHP(healTarget.GetHP() + healPerSec);
        }
        onceAttackAni = true;
        isHealing = false;
        healEffect.SetActive(false);
    }
Esempio n. 18
0
        public virtual object TryConstruct(ObjectBase objectBase, IEnumerable<object> otherArgs)
        {
            var inputs = (objectBase == null ? new object[0] : new[] { objectBase }).Concat(otherArgs).ToArray();
            if (inputs.Length != Parameters.Count)
                return null;

            for (var i = 0; i < inputs.Length; i++)
            {
                if (inputs[i] == null)
                {
                    if (Parameters.ElementAt(i).IsValueType)
                        return null;
                }
                else if (!Parameters.ElementAt(i).IsAssignableFrom(inputs[i].GetType()))
                {
                    return null;
                }
            }

            return _Constructor(inputs);
        }
Esempio n. 19
0
        public override void Collide(ObjectBase obj, Rectangle collision)
        {
            _tint = Color.Red;

            bool ejectHorizontal = collision.Width < collision.Height;

            if (ejectHorizontal)
            {
                if (this.Position.X <= collision.Left)
                    this.Position.X -= collision.Width - 1;
                else
                    this.Position.X += collision.Width + 1;
            }
            else
            {
                if (this.Position.Y <= collision.Top)
                    this.Position.Y -= collision.Height - 1;
                else
                    this.Position.Y += collision.Height + 1;
            }
        }
Esempio n. 20
0
        public void Sealed()
        {
            // Arrange
            var subject = new Constructors(typeof(C2));
            var objBase1 = new ObjectBase(Dx.Settings);

            var values = new MockBuilder();
            ((dynamic)values).Prop = "bye";

            var objBase2 = new ObjectBase(Dx.Settings, values);

            // Act
            // Assert
            Assert.AreEqual("Hi", ((C2)subject.Construct(objBase1)).Prop);
            Assert.AreEqual("bla", ((C2)subject.Construct(objBase1, new[] { "bla" })).Prop);
            Assert.AreEqual(null, ((C2)subject.Construct(objBase1, new[] { 55 as object })).Prop);

            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2)).Prop);
            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2, new[] { "bla" })).Prop);
            Assert.AreEqual("bye", ((C2)subject.Construct(objBase2, new[] { 55 as object })).Prop);
        }
Esempio n. 21
0
    List <ObjectBase> placedContent;            //The content the item had, but now are placed

    //Called at the beginning of the levels
    public void Start()
    {
        //Create the lists
        content       = new List <ObjectBase>();
        placedContent = new List <ObjectBase>();

        //If the item in the toolbox is available more than once, enable the counter, and set its number
        if (count > 1)
        {
            counter.gameObject.SetActive(true);
            counter.sprite = toolboxNumbers[count - 2];
        }

        //Spawn the required number of clones from the prefab
        for (int i = 0; i < count; i++)
        {
            ObjectBase go = (ObjectBase)Instantiate(normalPrefab, transform.position, Quaternion.identity);
            content.Add(go.GetComponent <ObjectBase>());

            go.transform.parent = this.transform;
            go.gameObject.SetActive(false);
        }
    }
Esempio n. 22
0
        private void addTemplateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Ask the user to select the type of Template
            ClassBase          godzClass = ClassBase.findClass("ObjectTemplate");
            ClassSelectionForm form      = new ClassSelectionForm(godzClass);

            if (form.ShowDialog() == DialogResult.OK)
            {
                //open up the template editor for this type...
                mTemplate = form.mSelectedType.newInstance();
                mTemplate.setPackage(mSelectedPackage);

                //Assign this object a package...
                mTemplate.setPackage(mSelectedPackage);

                object proxy = Editor.GetNewObjectProxy(mTemplate);
                propertyGrid1.SelectedObject = proxy;

                AddTemplateToTree(mPackageNode, mTemplate);

                Editor.AddEntity(mSelectedPackage.GetName(), mTemplate);
            }
        }
Esempio n. 23
0
        private void addSubObject(ObjectBase objbase, TreeNode parentnode)
        {
            uint   hash = objbase.getObjectName();
            string text;

            if (hash == 0)
            {
                ClassBase godzClass = objbase.getClass();
                text = godzClass.ClassName;
            }
            else
            {
                text = Editor.GetHashString(hash);
            }

            System.Windows.Forms.TreeNode subobjnode = new TreeNode(text);
            subobjnode.Tag     = objbase;
            objectMap[objbase] = subobjnode;

            parentnode.Nodes.Add(subobjnode);

            addSubProperties(objbase, subobjnode);
        }
Esempio n. 24
0
        private static void WriteGODynamic(ObjectBase obj, Character receiver, UpdatePacket packet)
        {
            var go = (GameObject)obj;

            if (go is Transport || !go.Flags.HasAnyFlag(GameObjectFlags.ConditionalInteraction))
            {
                packet.Write(obj.GetUInt32(GameObjectFields.DYNAMIC));
            }
            else
            {
                GODynamicLowFlags lowFlags;
                if (go.CanBeUsedBy(receiver))
                {
                    lowFlags = GODynamicLowFlags.Clickable | GODynamicLowFlags.Sparkle;
                }
                else
                {
                    lowFlags = GODynamicLowFlags.None;
                }
                packet.Write((ushort)lowFlags);
                packet.Write(ushort.MaxValue);
            }
        }
Esempio n. 25
0
    // 指引目标方位
    public bool GetGuideTargetDir(ref Vector3 dir)
    {
        ObjectBase owner = GetOwner();

        if (owner == null)
        {
            return(false);
        }

        if (mGuideTarget == null)
        {
            return(false);
        }

        Vector3 srcPos = mGuideTarget.GetPosition() - owner.GetPosition();

        srcPos.y = 0.0f;

        dir = Utility.RotateVectorByAngle(srcPos, -CameraController.Instance.CurCamera.transform.localEulerAngles.y, Vector3.zero);
        dir.Normalize();

        return(true);
    }
Esempio n. 26
0
    // 检测碰撞
    public bool TestCollider(ObjectBase obj)
    {
        if (obj == null)
        {
            return(false);
        }

        SceneShape myShape = GetShape();

        if (myShape == null)
        {
            return(false);
        }

        SceneShape objShape = obj.GetShape();

        if (objShape == null)
        {
            return(false);
        }

        return(myShape.intersect(objShape));
    }
Esempio n. 27
0
    public static bool LoadObject(Object gameObj, BinaryReader reader, ReaderOSGB owner)
    {
        string className = ReadString(reader);
        long   blockSize = ReadBracket(reader, owner);
        uint   id        = reader.ReadUInt32();

        className = className.Replace("::", "_");

        if (owner._sharedObjects.ContainsKey(id))
        {
            //Debug.Log("Shared object " + className + "-" + id);
            return(true);  // TODO: how to share nodes?
        }
        else
        {
            owner._sharedObjects[id] = gameObj;
        }

        System.Type classType = System.Type.GetType(className);
        if (classType == null)
        {
            Debug.LogWarning("Object type " + className + " not implemented");
            return(false);
        }

        ObjectBase classObj = System.Activator.CreateInstance(classType) as ObjectBase;

        if (classObj == null)
        {
            Debug.LogWarning("Object instance " + className + " failed to create");
            return(false);
        }
        else
        {
            return(classObj.read(gameObj, reader, owner));
        }
    }
Esempio n. 28
0
        /// <inheritdoc />
        public bool Rename(DbRef reference, string newName)
        {
            if (string.IsNullOrWhiteSpace(newName))
            {
                return(false);
            }

            var cts          = new CancellationTokenSource(5000);                     // 5 seconds
            var getAsyncTask = ObjectBase.GetAsync(this.redis, reference, cts.Token); // 5 seconds

            if (!getAsyncTask.Wait(5000))
            {
                return(false);
            }

            var target = getAsyncTask.Result;

            if (target == null)
            {
                return(false);
            }

            if (!target.Owner.Equals(this.caller.DbRef))
            {
                return(false);
            }

            target.Name = newName;
            var saveAsyncTask = target.SaveAsync(this.redis, cts.Token);

            if (!saveAsyncTask.Wait(5000))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 29
0
    //结算受击效果
    private void OnObjectHitted(ObjectBase caster, ObjectBase target, int reduceHp, int reduceArmor)
    {
        List <BuffInst> lstBuffInst = new List <BuffInst>(target.lstBuffInst);

        foreach (var buffInst in lstBuffInst)
        {
            BuffTemplate template = BuffTemplateData.GetData(buffInst.tplId);
            if (template == null)
            {
                continue;
            }
            switch (template.nType)
            {
            case BuffType.ARMOR_REFLECT:
                if (0 == reduceArmor)
                {
                    continue;
                }

                int reflectValue = (reduceArmor * buffInst.effectVal) / 100;
                _battleModel.ReduceEnemyHp(caster.instId, reflectValue);
                break;

            case BuffType.MULTI_ARMOR:
                if (reduceHp > 0)
                {
                    //受伤少一层护甲
                    _battleModel.DecBuffEffectVal(target, buffInst, 1);
                }
                break;

            default:
                //Debug.LogError("unhandle on hit buff type:" + template.nType);
                break;
            }
        }
    }
Esempio n. 30
0
    public void RecoverScene()
    {
        if (mSceneMask != null)
        {
            mSceneMask.enabled = false;
        }
        SceneObjManager objMng = SceneManager.Instance.GetCurScene().GetSceneObjManager();

        //还原场景中的物体的渲染队列
        foreach (DarkTask task in mDarkExcludeList)
        {
            ObjectBase obj = objMng.FindObject(task.instID);
            if (obj == null)
            {
                continue;
            }
            VisualObject vObj = obj as VisualObject;
            if (vObj == null)
            {
                continue;
            }
            if (task.queue == null || vObj.OriginalInstMtl == null || task.queue.Length != vObj.OriginalInstMtl.Length)
            {
                continue;
            }
            for (int i = 0; i < vObj.OriginalInstMtl.Length; ++i)
            {
                Material mtl = vObj.OriginalInstMtl[i];
                if (mtl == null)
                {
                    continue;
                }
                mtl.renderQueue = task.queue[i];
            }
        }
        mDarkExcludeList.Clear();
    }
    public RuntimeAnimatorController Creat()
    {
        AnimatorController controller = new AnimatorController();

        controller.AddParameter(ActionConst.WALK, AnimatorControllerParameterType.Bool);
        controller.AddParameter(ActionConst.HELLO, AnimatorControllerParameterType.Bool);
        controller.AddParameter(ActionConst.TALK, AnimatorControllerParameterType.Bool);
        controller.AddParameter(ActionConst.CHANGE_CLOTH, AnimatorControllerParameterType.Bool);

        //if(CharacterConst.useExpAnim)
        //{
        //    controller.AddParameter(ActionConst.EXP_SMILE, AnimatorControllerParameterType.Bool);
        //    controller.AddParameter(ActionConst.EXP_TALK, AnimatorControllerParameterType.Bool);
        //}

        IObjectBase objBase = new ObjectBase(AnimPath);

        objBase.CreatAsset(controller);

        IEditorAnimationLayer baselayer = new EditorAnimationLayer_base(resType, controller, sex);

        baselayer.Create();
        IEditorAnimationLayer fittingroomlayer = new EditorAnimationLayer_fittingroom(resType, controller, sex);

        fittingroomlayer.Create();

        //if (CharacterConst.useExpAnim)
        //{
        //    IEditorAnimationLayer expressionlayer = new EditorAnimationLayer_expression(controller, sex);
        //    expressionlayer.Create();
        //}


        objBase.ImportAsset(ImportAssetOptions.ForceUpdate);

        return(controller);
    }
Esempio n. 32
0
        /// <summary>
        /// Returns a A8R8G8B8 (pow2 sized) bitmap with the name of the object drawn in it.
        /// </summary>
        /// <param name="Object"></param>
        /// <returns></returns>
        public static Bitmap GetBitmapForName(ObjectBase Object)
        {
            const int ESTIMATEDCHARWIDTH = 16;
            const int HEIGHT             = 32;

            int width = (int)MathUtil.NextPowerOf2((uint)(Object.Name.Length * ESTIMATEDCHARWIDTH));

            // get color to use for name based on objectflags
            Color color = Color.FromArgb((int)NameColors.GetColorFor(Object.Flags));

            // font to use
            Font font = new Font(FontFamily.GenericSansSerif, 20,
                                 FontStyle.Regular, GraphicsUnit.Pixel);

            // create bitmap to draw on
            Bitmap bitmap = new Bitmap(width, HEIGHT, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            // draw name into bitmap
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                string text = Object.Name;

                StringFormat format = new StringFormat();
                format.Alignment     = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;

                // draw text
                using (SolidBrush brush = new SolidBrush(color))
                {
                    g.Clear(Color.Transparent);
                    g.DrawString(text, font, brush, new RectangleF(0, 0, width, HEIGHT), format);
                }
            }

            return(bitmap);
        }
Esempio n. 33
0
        protected override void FillInList(ITypeDescriptorContext context, IServiceProvider provider, ListBox listBox)
        {
            //Note: ITypeDescriptorContext contains the Instance object

            // find out which mesh/package it was....
            ObjectBaseProxy     objProxy    = (ObjectBaseProxy)context.Instance;
            PropertyContextData contextData = objProxy.contextData;

            ClassPropertyInfo packageProperty = contextData.context1.getPropertyValue("Model");
            ObjectBase        oo = packageProperty.mObject;

            if (oo != null && oo is Mesh)
            {
                Mesh m = (Mesh)oo;

                List <String> animList = new List <string>();
                m.getAnimations(animList);

                foreach (string animName in animList)
                {
                    listBox.Items.Add(animName);
                }
            }
        }
Esempio n. 34
0
    public virtual void EnterObject(ObjectBase targetObject)
    {
        if (AskEnterable() == false)
        {
            return;
        }

        if (Objects.ContainsKey(targetObject.ObjectID))
        {
            Debug.Log($"{ObjectID} 이미 들어 왔는데? : {targetObject.ObjectID }");
        }
        Objects.Add(targetObject.ObjectID, targetObject);

        Debug.Log("Enter");
        targetObject.transform.parent = this.transform;
        var meshRenderer = targetObject.GetComponentInChildren <MeshRenderer>() as MeshRenderer;

        if (meshRenderer != null)
        {
            meshRenderer.enabled = false;
        }

        CurrentCapacity++;
    }
Esempio n. 35
0
        private void AddTemplateToTree(TreeNode packageNode, ObjectBase obj)
        {
            String objName;
            uint   objnameHash = obj.getObjectName();

            objName = Editor.GetHashString(objnameHash);


            if (objName == null)
            {
                objName = obj.getClass().ClassName;
            }

            System.Windows.Forms.TreeNode objectNode = new TreeNode(objName);
            packageNode.Nodes.Add(objectNode);
            objectNode.Tag = obj;
            objectNode.ContextMenuStrip = templateNodeContextMenuStrip1;
            objectMap[obj] = objectNode;

            //mTemplateNode = objectNode;

            //Add on properties....
            addSubProperties(obj, objectNode);
        }
Esempio n. 36
0
    public void CollisionCheck(ObjectBase obj, Define.BulletTeam targetTeam)
    {
        ObjectLink <BulletBase> link = activeFront;

        if (link == null)
        {
            return;
        }

        while (true)
        {
            link.me.CopyList();

            if (link.me.gameObject.activeSelf)
            {
                if (link.me.IsTeam(targetTeam))
                {
                    link.me.CollisionCheck(obj);
                    // if(obj.Collision(link.me))
                    // {
                    //  //Debug.Log(obj.GetColliderInfo().radius);
                    //  link.me.ColliseionActive(obj);
                    // }
                }
            }

            //link.me.DeleteExitObjects();

            link = link.back;

            if (link == null)
            {
                break;
            }
        }
    }
Esempio n. 37
0
    /// <summary>
    /// 减少buff剩余回合数
    /// </summary>
    /// <param name="buffInst"></param>
    internal void DecBuffLeftBout(ObjectBase targetObject, BuffInst buffInst, int iDec)
    {
        if (buffInst.leftBout == -1)
        {
            return;
        }

        if (buffInst.leftBout <= iDec)
        {
            RemoveBuff(targetObject, buffInst);
        }
        else
        {
            buffInst.leftBout -= iDec;
            if (targetObject.objType == ObjectType.PLAYER)
            {
                SendEvent(BattleEvent.SELF_BUFF_UPDATE, buffInst);
            }
            else if (targetObject.objType == ObjectType.ENEMY)
            {
                SendEvent(BattleEvent.ENEMY_BUFF_UPDATE, buffInst);
            }
        }
    }
Esempio n. 38
0
    /// <summary>
    /// 减少buff效果值
    /// </summary>
    /// <param name="buffInst"></param>
    internal void DecBuffEffectVal(ObjectBase targetObject, BuffInst buffInst, int iDec)
    {
        if (buffInst.effectVal == 0)
        {
            return;
        }

        if (buffInst.effectVal <= iDec)
        {
            RemoveBuff(targetObject, buffInst);
        }
        else
        {
            buffInst.effectVal -= iDec;
            if (targetObject.objType == ObjectType.PLAYER)
            {
                SendEvent(BattleEvent.SELF_BUFF_UPDATE, buffInst);
            }
            else if (targetObject.objType == ObjectType.ENEMY)
            {
                SendEvent(BattleEvent.ENEMY_BUFF_UPDATE, buffInst);
            }
        }
    }
Esempio n. 39
0
    private bool MoneyChange(ObjectBase obj, ArrayList param)
    {
        if (obj == null || param == null)
        {
            return(false);
        }

        if (param.Count != 2)
        {
            GameDebug.Log("usage: .money [0:type 1:value] ");
            return(false);
        }

        if (obj is Player)
        {
            //PlayerDataModule module = ModuleManager.Instance.FindModule<PlayerDataModule>();

            //module.ChangeProceeds((ProceedsType)(System.Convert.ToInt32(param[0])), System.Convert.ToInt32(param[1]));

            return(true);
        }

        return(false);
    }
Esempio n. 40
0
    override public void OnSpriteEnterScene(ObjectBase sprite)
    {
        Npc npc = sprite as Npc;

        if (npc == null)
        {
            return;
        }

        if (string.Compare(npc.GetAlias(), "monster") != 0)
        {
            return;
        }

        mMonsterCount++;

        EventSystem.Instance.PushEvent(new YaZhiXieEUpdateScoreEvent(mScore, mMonsterCount));

        if (mMonsterCount >= GameConfig.YZXEMonsterMaxCount)
        {
            SetResult(0);
            pass();
        }
    }
Esempio n. 41
0
    override public ObjectBase CreateMainPlayer()
    {
        GhostInitParam initParam = new GhostInitParam();

        initParam.init_pos   = GetInitPos();
        initParam.init_pos.y = GetHeight(initParam.init_pos.x, initParam.init_pos.z);
        initParam.init_dir   = GetInitDir();
        initParam.ghost_data.SyncProperty(PlayerDataPool.Instance.MainData);
        initParam.league      = LeagueDef.Red;
        initParam.main_player = true;

        ObjectBase playerGhost = CreateSprite(initParam);

        if (playerGhost == null)
        {
            return(null);
        }

        SetOwner(playerGhost);

        PlayerController.Instance.SetControl(playerGhost.InstanceID);        //uint.MaxValue);

        return(playerGhost);
    }
Esempio n. 42
0
    private void Interactions()
    {
        if (currentItem && Input.GetAxis("P" + playerNumber + "_Action_Axis") == 1f && Time.time > (lastPickupTime + beforeUseCooldown))
        {
            if (currentItem.Utilisation(transform.rotation.eulerAngles.y, this))
            {
                currentItem = null;
            }
        }
        else if (itemInRange && Time.time > (lastPickupTime + pickupCooldown) && Input.GetAxis("P" + playerNumber + "_Action_Axis") == 1f)
        {
            lastPickupTime = Time.time;
            currentItem    = itemInRange;

            // Remove picked up item from in range, from all players
            foreach (PlayerController pc in _players)
            {
                if (pc.GetItemInRange() == currentItem)
                {
                    pc.SetItemInRange(null);
                }
            }

            // Remove pickup script and light and particles from current item
            ObjectPickUp pk = currentItem.gameObject.GetComponent <ObjectPickUp>();
            Destroy(pk.Light.gameObject);
            Destroy(pk.Particles.gameObject);
            Destroy(pk);

            SoundManager.Instance.PlaySFX("Pickup", SoundManager.DefaultTypes.UseItem);
            animator.SetBool("InRange", true);  // PICKUP ANIMATION
            animator.SetTrigger("UseRT");       // PICKUP ANIMATION

            animator.SetBool("InRange", false); // RESET MULTI CONDITION
        }
    }
Esempio n. 43
0
    //触发器不参与判断,返回false
    public static bool IsInCollision(ObjectBase ob)
    {
        ObjectCollider c = ob.GetComponent <ObjectCollider>();

        if (c == null)
        {
            return(false);
        }

        LinkedListNode <ObjectCollider> node = colliderList.First;

        while (node != null)
        {
            if (node.Value != c && !node.Value.isTrriger)           //不要和自己比较
            {
                if (IsCollision(c, node.Value))
                {
                    return(true);
                }
            }
            node = node.Next;
        }
        return(false);
    }
Esempio n. 44
0
 public override void OnUpdate(AchievementCollection achievements, uint value1, uint value2, ObjectBase involved)
 {
     achievements.SetCriteriaProgress((AchievementCriteriaEntry)this, 1U, ProgressType.ProgressAccumulate);
 }
Esempio n. 45
0
    protected override void DieAward(uint killerid)
    {
        if (mRes == null)
        {
            return;
        }

        // 掉货币
        if (mRes.dropMoney > 0 && mRes.dropMoneyWeight > 0)
        {
            int rand = Random.Range(0, DropManager.MAX_WEIGHT);
            if (mRes.dropMoneyWeight > rand)
            {
                if (mRes.dropMoneyPickId < 0 || !DataManager.PickTable.ContainsKey(mRes.dropMoneyPickId))
                {
                    if (killerid != uint.MaxValue)
                    {
                        ObjectBase obj = PlayerController.Instance.GetControlObj();
                        if (obj != null && obj.InstanceID == killerid)
                        {
                            PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                            if (pdm != null)
                            {
                                //  pdm.ChangeProceeds(ProceedsType.Money_Game, mRes.dropMoney);
                            }
                        }
                    }
                }
                else
                {// 掉进场景
                    List <PickInitParam> paramList = new List <PickInitParam>();
                    if (SceneObjManager.CreatePickInitParam(Pick.PickType.MONEY, mRes.dropMoneyPickId, mRes.dropMoney, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, false))
                    {
                        foreach (PickInitParam param in paramList)
                        {
                            mScene.CreateSprite(param);
                        }
                    }
                }
            }
        }

        // 掉buff
        if (mRes.buffDropBoxId >= 0)
        {
            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam(Pick.PickType.BUFF, -1, mRes.buffDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
            {
                foreach (PickInitParam param in paramList)
                {
                    mScene.CreateSprite(param);
                }
            }
        }

        // 掉道具
        if (mRes.itemDropBoxId >= 0)
        {
            if (mRes.isDropOnGround > 0)
            {// 掉地上
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, mRes.itemDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
//             else
//             {
//                 ArrayList itemList = new ArrayList();
//                 if (DropManager.Instance.GenerateDropBox(mRes.itemDropBoxId, out itemList))
//                 {
//                     foreach (DropBoxItem item in itemList)
//                     {
//                         ItemTableItem itemres = ItemManager.GetItemRes(item.itemid);
//                         if (itemres == null)
//                             continue;
//
//                         if (killerid != uint.MaxValue)
//                         {
//                             ObjectBase obj = PlayerController.Instance.GetControlObj();
//                             if (obj != null && obj.InstanceID == killerid)
//                             {
//                                 PlayerDataModule pdm = ModuleManager.Instance.FindModule<PlayerDataModule>();
//                                 if (pdm != null)
//                                 {
//                                     //pdm.CreateItemUnreal(item.itemid, PackageType.Pack_Bag);
//                                 }
//                             }
//                         }
//                     }
//                 }
//             }
        }
    }
Esempio n. 46
0
    public override void HpDamageAward(uint objtarget, int time)
    {
        if (mRes == null)
        {
            return;
        }

        if (uint.MaxValue == objtarget)
        {
            return;
        }

        if (0 == cdTime)
        {
            cdTime = time * 1000;
        }
        else
        {
            return;
        }

        // 掉货币
        if (mRes.dropMoney > 0 && mRes.dropMoneyWeight > 0)
        {
            int rand = Random.Range(0, DropManager.MAX_WEIGHT);
            if (mRes.dropMoneyWeight > rand)
            {
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.MONEY, mRes.dropMoneyPickId, mRes.dropMoney, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, false))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
        }

        // 掉buff
        if (mRes.buffDropBoxId >= 0)
        {
            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam(Pick.PickType.BUFF, -1, mRes.buffDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
            {
                foreach (PickInitParam param in paramList)
                {
                    mScene.CreateSprite(param);
                }
            }
        }

        // 掉道具
        if (mRes.itemDropBoxId >= 0)
        {
            if (mRes.isDropOnGround > 0)
            {            // 掉地上
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, mRes.itemDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
            else
            {
                ArrayList itemList = new ArrayList();
                if (DropManager.Instance.GenerateDropBox(mRes.itemDropBoxId, out itemList))
                {
                    foreach (DropBoxItem item in itemList)
                    {
                        ItemTableItem itemres = ItemManager.GetItemRes(item.itemid);
                        if (itemres == null)
                        {
                            continue;
                        }

                        ObjectBase obj = PlayerController.Instance.GetControlObj();
                        if (obj != null)
                        {
                            PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                            if (pdm != null)
                            {
                                //pdm.CreateItemUnreal(item.itemid, PackageType.Pack_Bag);
                            }
                        }
                    }
                }
            }
        }
    }
        public static bool IsNavigable(this ObjectBase obj, string propertyName)
        {
            PropertyInfo propertyInfo = obj.GetType().GetProperty(propertyName);

            return(propertyInfo.IsNavigable());
        }
Esempio n. 48
0
 public void SetItemInRange(ObjectBase obj)
 {
     itemInRange = obj;
 }
Esempio n. 49
0
    //Drops the selected item
    void DropItem()
    {
        //Render the object on it's original order
        ChangeSortingOrderBy(selectedObject.gameObject, -3);

        // set feedback to rotation as soon as object is selected and on mouse button up
        TransformObjectManager.Instance.Setup(selectedObject, TransformObjectManager.TargetState.rotating);
        pItemSlected = false;
        //If the object is in a valid position
        if (selectedObject.GetValidPos())
        {
            //Drop it and add it to the active items
            selectedObject.Dropped();
            selectedObject.Setup();
            LevelDesignManager.Instance.AddItem(selectedObject.GetComponent<ObjectBase>());

            //If the object can be rotated, change the feedback to rotation
            if (selectedObject.canRotate)
            {
                TransformObjectManager.Instance.Setup(selectedObject, TransformObjectManager.TargetState.rotating);
            }
            else
            {
                TransformObjectManager.Instance.Disable(0);
                HideFeedback();
                selectedObject = null;
            }
        }
        else
        {
            //Puts it to previous valid position if dropped to a invalid position
            //if placed from BackPack to a invalid position put it back to BackPack
            if( fromBackPack ==false)
            {
                //the object is dropped in invalid position
                selectedObject.transform.position = lastPosition;
                selectedObject.SetValidPos(true);
            }
            else if ( fromBackPack == true)
            {
                //Put the item back to the BackPack
                BackPackManager.Instance.AddItem(selectedObject);
                LevelDesignManager.Instance.RemoveItem(selectedObject.GetComponent<ObjectBase>());
                TransformObjectManager.Instance.Disable(0);

                selectedObject = null;
                HideFeedback();
            }
        }

        //Reset item variables

        offset = Vector3.zero;
        selectedItem = null;
        itemSelectionValid = false;

        //Set input state
        inputState = InputState.waitingForInput;
    }
        //Set taget object and state, then scales the feedback to the target
        public void Setup(ObjectBase target, TargetState state)
        {
            targetState = state;

            this.target = target;
            feedback.sortingOrder = 4;

            StopCoroutine("Rescale");
            StartCoroutine(Rescale(feedback.transform, target.GetFeedbackSize(), 0.2f));
        }
Esempio n. 51
0
        ///// <summary>
        ///// Unused
        ///// </summary>
        //public static void SendMagicResist(ObjectBase caster, ObjectBase target, uint spellId)
        //{
        //    using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_RESISTLOG, 21))
        //    {
        //        caster.EntityId.WritePacked(packet);
        //        target.EntityId.WritePacked(packet);
        //        packet.WriteUInt(spellId);
        //        packet.WriteByte((byte)0);
        //    }
        //}

        /// <summary>
        /// Correct for 3.0.9
        /// </summary>
        /// <param name="target">Optional</param>
        /// <param name="value">Optional</param>
        public static RealmPacketOut SendSpellLogExecute(ObjectBase caster, uint spellId, SpellEffectType effect, ObjectBase target, uint value)
        {
            // TODO: Info we still need for this packet: spellId of interrupted spell, itemId of created item

            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLLOGEXECUTE, 37);

            caster.EntityId.WritePacked(packet);
            packet.Write(spellId);
            const int effectCount = 1;

            packet.Write(effectCount);

            for (int i = 0; i < effectCount; i++)
            {
                packet.Write((int)effect);
                const int targetCount = 1;                 // unsure

                for (int j = 0; j < targetCount; j++)
                {
                    switch (effect)
                    {
                    case SpellEffectType.PowerDrain:
                    {
                        target.EntityId.WritePacked(packet);
                        packet.Write(0);
                        packet.Write(0);
                        packet.Write(0.0f);
                        break;
                    }

                    case SpellEffectType.AddExtraAttacks:
                    {
                        target.EntityId.WritePacked(packet);
                        packet.Write(0);
                        break;
                    }

                    case SpellEffectType.InterruptCast:
                    {
                        packet.Write(0);                                         // spellId of interrupted spell
                        break;
                    }

                    case SpellEffectType.DurabilityDamage:
                    {
                        packet.Write(0);
                        packet.Write(0);
                        break;
                    }

                    case SpellEffectType.OpenLock:
                    case SpellEffectType.OpenLockItem:
                    {
                        if (target is Item)
                        {
                            target.EntityId.WritePacked(packet);
                        }
                        else
                        {
                            packet.Write((byte)0);
                        }
                        break;
                    }

                    case SpellEffectType.CreateItem:
                    case SpellEffectType.CreateItem2:
                    {
                        packet.Write(0);                                         // itemId
                        break;
                    }

                    case SpellEffectType.Summon:
                    case SpellEffectType.TransformItem:
                    case SpellEffectType.SummonPet:
                    case SpellEffectType.SummonObjectWild:
                    case SpellEffectType.CreateHouse:
                    case SpellEffectType.Duel:
                    case SpellEffectType.SummonObjectSlot1:
                    case SpellEffectType.SummonObjectSlot2:
                    case SpellEffectType.SummonObjectSlot3:
                    case SpellEffectType.SummonObjectSlot4:
                    {
                        if (target is Unit)
                        {
                            target.EntityId.WritePacked(packet);                                             // summon recipient
                        }
                        else
                        {
                            packet.Write((byte)0);
                        }
                        break;
                    }

                    case SpellEffectType.FeedPet:
                    {
                        if (target is Item)
                        {
                            packet.Write(target.EntryId);
                        }
                        else
                        {
                            packet.Write(0);
                        }
                        break;
                    }

                    case SpellEffectType.DismissPet:
                    {
                        target.EntityId.WritePacked(packet);
                        break;
                    }

                    case SpellEffectType.Resurrect:
                    case SpellEffectType.ResurrectFlat:
                    {
                        if (target is Unit)
                        {
                            target.EntityId.WritePacked(packet);
                        }
                        else
                        {
                            packet.Write((byte)0);
                        }
                        break;
                    }
                    }
                }
            }

            return(packet);
        }
Esempio n. 52
0
            public void CheckForCollision(ObjectBase objectA, ObjectBase objectB)
            {
                Rectangle a = objectA.CollisionRectangle;
                Rectangle b = objectB.CollisionRectangle;

                int collisionWidth = 0;
                int collisionHeight = 0;
                int collisionX = 0;
                int collisionY = 0;

                if (a.Left < b.Left)
                {
                    collisionWidth = GetCollisionWidth(a, b);
                    collisionX = b.Left;
                }
                else
                {
                    collisionWidth = GetCollisionWidth(b, a);
                    collisionX = a.Left;
                }

                if (a.Top < b.Top)
                {
                    collisionHeight = GetCollisionHeight(a, b);
                    collisionY = b.Top;
                }
                else
                {
                    collisionHeight = GetCollisionHeight(b, a);
                    collisionY = a.Top;
                }

                if (collisionWidth < 0 || collisionHeight < 0)
                    return;

                Rectangle collision = new Rectangle(collisionX, collisionY, collisionWidth, collisionHeight);
                objectA.Collide(objectB, collision);
            }
Esempio n. 53
0
    public void RemoveSelectedLevelItem()
    {
        if(selectedObject != null && selectedObject.GetValidPos())
        {
            //Put the item back to the BackPack
            BackPackManager.Instance.AddItem(selectedObject);
            LevelDesignManager.Instance.RemoveItem(selectedObject.GetComponent<ObjectBase>());
            TransformObjectManager.Instance.Disable(0);

            selectedObject = null;
        }

        //Reset item variables
        offset = Vector3.zero;
        selectedItem = null;
        itemSelectionValid = false;

        pItemSlected = false;

        //Set input states
        inputState = InputState.waitingForInput;

        if(hasFeedback)
            HideFeedback();
    }
Esempio n. 54
0
    //Called when there are no specific input and waiting for one
    void ScanForInput()
    {
        if (HasInput())
        {
            //If the input was registered
            if (hit.collider != null)
            {
                if (hit.transform.tag == "GUI")
                {
                    if (hasFeedback)
                        HideFeedback();

                    GUIManager.Instance.ReceiveInput(hit.transform);
                }

                else if (hit.transform.tag == "BackPack")
                    PrepareScrolling(hit.transform);

                else if (hit.transform.tag == "GameObject")
                    PrepareToDrag(hit.transform, false);

                else if (hit.transform.tag == "Feedback")
                    PrepareToRotate();

            }
            //If we have an active feedback, and the input was in an empty space, hide the feedback
            else if (hasFeedback)
            {
                selectedObject = null;
                HideFeedback();
            }
        }
    }
Esempio n. 55
0
    //Prepares the selected item for dragging
    void PrepareToDrag(Transform item, bool fromBackPack)
    {
        //If the level is in play mode, return to caller
        if (LevelDesignManager.Instance.InPlayMode())
            return;

        //If we have an active feedback, hide it
        if (hasFeedback && selectedObject != null)
            HideFeedback();

        //If the object is from the BackPack
        if (fromBackPack)
        {
            fromBackPack = true;
            //Remove the object from the BackPack, and select it
            selectedObject = item.GetComponent<BackPackItemType>().RemoveItem();
            selectedObject.DragMode();
            selectedObject.PlayPickupAnimation();

            //Activate the feedback on the object
            TransformObjectManager.Instance.Setup(selectedObject, TransformObjectManager.TargetState.dragging);
            hasFeedback = true;

            //Render the object to the top
            ChangeSortingOrderBy(selectedObject.gameObject, 3);
            inputState = InputState.moving;

        }
        //If the object is not from the BackPack, make sure it can be dragged
        else if (CanDragged(item))
        {
            fromBackPack = false;
            //It is possible we have selected its child collider, so scan it for the ObjectBase script
            selectedObject = GetParent(item);

            selectedObject.DragMode();

            //Calculate offset based on input position
            offset = new Vector3(inputPos.x - selectedObject.transform.position.x, inputPos.y - selectedObject.transform.position.y, 0);

            //Activate feedback on the selected item
            TransformObjectManager.Instance.Setup(selectedObject, TransformObjectManager.TargetState.dragging);
            hasFeedback = true;

            //Render the object to the top
            ChangeSortingOrderBy(selectedObject.gameObject, 3);
            inputState = InputState.moving;
            lastPosition = selectedObject.transform.position;
            if ( selectedObject != null )
            {
                pItemSlected = true;
            }
        }
        //if item already existing item which cant be dragged
        else
        {
            selectedObject = null;
        }
    }
Esempio n. 56
0
 public override bool CanEnterIn(ObjectBase obj)
 {
     return true;
 }
Esempio n. 57
0
 public override bool CanThroughSlantWise(ObjectBase obj)
 {
     return true;
 }
Esempio n. 58
0
 public void AddActiveObject(ObjectBase obj)
 {
     _activeObjects.Add(obj);
 }
Esempio n. 59
0
        /// <summary>
        /// Correct for 3.0.9
        /// </summary>
        /// <param name="client"></param>
        /// <param name="obj1"></param>
        /// <param name="obj2"></param>
        /// <param name="spellId"></param>
        /// <param name="b1"></param>
        public static void SendSpellOrDamageImmune(IPacketReceiver client, ObjectBase obj1, ObjectBase obj2, int spellId, bool b1)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLORDAMAGE_IMMUNE, 21))
            {
                packet.Write(obj1.EntityId);
                packet.Write(obj2.EntityId);
                packet.Write(spellId);
                packet.Write(b1);

                client.Send(packet, addEnd: false);
            }
        }
Esempio n. 60
0
        object BuildObject(IEnumerable<object> constructorArgs)
        {
            Compile();

            var obj = new ObjectBase(Settings, MockInfo);
            if (Settings.TestForInvalidMocks)
            {
                var errors = ObjectBaseValidator.Create(MockType).ValidateAgainstType(obj);
                if (errors.Any())
                    throw new InvalidMockException(string.Join(Environment.NewLine, new[] { "Errors detected when attempting to mock " + MockType }.Concat(errors)));
            }

            return Constructors[MockType].Construct(obj, constructorArgs);
        }