Ejemplo n.º 1
0
        private void CreateModelingTool(Type toolType)
        {
            if (lastActiveTool != null)
            {
                if (lastActiveTool.GetType() == toolType)
                {
                    lastActiveTool.Deactivate();
                    lastActiveTool = new DefaultTool(this);
                    lastActiveTool.Activate();
                    return;
                }
                else
                {
                    lastActiveTool.Deactivate();
                    lastActiveTool = null;
                }
            }

            Type[] types = new Type[1];
            types[0] = typeof(GEMS.Designer.MainForm);
            ConstructorInfo constructorInfoObj = toolType.GetConstructor(types);

            object[] paras = new object[1];
            paras[0]       = this;
            lastActiveTool = (Tool)constructorInfoObj.Invoke(paras);
            lastActiveTool.Activate();
        }
Ejemplo n.º 2
0
    void ActivateTool(Tool tool)
    {
        if (tool == activeTool)
        {
            return;
        }
        if (activeTool != null)
        {
            var btn = activeTool.GetComponent <Button>();
            var cb  = btn.colors;
            cb.normalColor = Color.white;
            btn.colors     = cb;

            activeTool.Deactivate();
        }
        activeTool = tool;
        if (activeTool != null)
        {
            var btn = activeTool.GetComponent <Button>();
            var cb  = btn.colors;
            cb.normalColor = pressedColor;
            btn.colors     = cb;
            activeTool.Activate();
            description.text = activeTool.GetDescription();
        }
    }
Ejemplo n.º 3
0
    void ChangeTool(int newIndex)
    {
        if (newIndex < 0)
        {
            toolIndex = tools.Count - 1;
        }
        else if (newIndex > tools.Count - 1)
        {
            toolIndex = 0;
        }
        else
        {
            toolIndex = newIndex;
        }

        if (selectedTool != null)
        {
            selectedTool.Deactivate();
        }
        selectedTool = (tools[toolIndex]);
        selectedTool.Activate();
        selectedTool.Feedback("Switched to " + selectedTool.toolName);
    }
Ejemplo n.º 4
0
    void Update()
    {
        if (paused)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                paused         = false;
                animator.speed = 0.6f;
                //setFade in
                isFadingIn = true;
                color      = Calc.GetColor(val - 1);
                color.a    = 0;
            }
        }
        if (isFadingIn)
        {
            float changeRate = 0.4f;
            color.a = color.a + changeRate * Time.deltaTime;
            if (color.a >= 0.5f)
            {
                isFadingIn = false;
                color.a    = 0.5f;
            }
            rend.material.color = color;
        }

        if (willMix)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                //Wave();
                willMix = false;
                //UpdateColor();
                createEffect = true;
                mixTimer     = 1.0f;
                isMixing     = true;
                newColor     = Calc.GetColor(val - 1);
                newColor.a   = 0.5f;
                if (addColorVal != -1)
                {
                    CreateAddColorFX();
                    Wave();
                    addColorVal = -1;
                }
            }
        }
        if (isMixing)
        {
            float mixRate = 1.0f;
            mixTimer -= Time.deltaTime * mixRate;

            if (mixTimer <= 0)
            {
                isMixing = false;
                mixTimer = 0;
                color    = newColor;
            }
            Color c = Color.Lerp(newColor, color, mixTimer);
            rend.material.color = c;
        }

        if (willClear)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                willClear = false;
                Clear(0, activeTool);
            }
        }
        if (willNova)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                willNova = false;
                //finds if other hexes need to nova
                gridManager.Nova(this);

                //do the nova effect
                activeTool.Activate(this);
                //Clear();
            }
        }
        if (willAbsorb)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                CreateAbsorb();
                willAbsorb = false;
            }
        }
        if (isFading)
        {
            float fadeRate = 1.0f;
            timer -= Time.deltaTime * fadeRate;
            Color c = new Color(0, 0, 0, 0);
            rend.material.color = Color.Lerp(c, color, timer);
        }
        if (willFlip)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                Flip();
                willFlip = false;
            }
        }
    }
Ejemplo n.º 5
0
    public override bool ContinueStateAction()
    {
        Unit unit = _brain.GetUnit();
        Tool tool = GetTool();

        if (unit == null || tool == null)
        {
            return(false);
        }

        tool.SetFlag(Tool.ENTITY_TOOL_FLAG_IN_USE);

        if ((GetFlags() & ASR_COMPLETED) == 0 && !tool.CanOrder())
        {
            return(false);
        }
        Debug.Log("ContinueStateAction111111111111111111111111111111111");
        if (tool.IsDisabled())
        {
            return(false);
        }
        Debug.Log("ContinueStateAction2222222222222222222222222222222");
        if (unit.IsStunned() && !tool.NoStun)
        {
            SetFlag(ASR_INTERRUPTED);
            return(false);
        }
        Debug.Log("ContinueStateAction3333333333333333333333333333333333");
        uint actionTime = 0;
        uint castTime   = 0;

        actionTime = tool.GetAdjustedActionTime();
        castTime   = tool.GetAdjustedCastTime();

        if (_initTime == 0)
        {
            //转向
            _initTime = Game._instance.GetGameTime();
            Debug.Log(_initTime);
            //动画
            if ((int)unit.GetAnim() != tool._castAction)
            {
                unit.SetAnim((EActionStateAnim)tool._castAction);
            }
        }

        uint elapsedTime = Game._instance.GetGameTime() - _initTime;
        bool ret         = true;

        if (elapsedTime < actionTime)
        {
            //commited
            SetFlag(ASR_COMMITTED);
        }
        else
        {
            //及调用tool的activate
            if ((GetFlags() & ASR_COMPLETED) == 0)
            {
                tool.Activate(null, _v3TargetPostion, _v3Delta, _issuedClientNumber);
                SetFlag(ASR_COMPLETED);
            }
        }

        Debug.Log("ContinueStateAction4444444444444444444444444444444444444");
        if (elapsedTime >= castTime && (GetFlags() & ASR_COMPLETED) != 0)
        {
            SetFlag(ASR_ALLDONE);
            ret = false;
        }
        Debug.Log("ContinueStateAction55555555555555555555555555555555555555");
        return(ret);
    }